PHP - 仅通过Facebook图形从Facebook页面发布数据 [英] PHP - Get post data from Facebook page using only facebook graph

查看:120
本文介绍了PHP - 仅通过Facebook图形从Facebook页面发布数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用简单的 php Facebook 页面的内容 c>。

is there a way to get Facebook page the contents of an post using simple php.

我不需要使用 Php-sdk Facebook API ,只能使用 Facebook图表 Facebook应用程序

i need to do that without The Php-sdk or the Facebook API only using the Facebook Graph and Facebook app

推荐答案

p>

I have found the solution

<?php
error_reporting(0);
/*xxxxclient_idxxx='your clientid'*/
/*xxxxxxclient_secretxxxx='your client_secret'*/
//Replace "YOUR-PAGE-NAME" with your page name.
$access_str = file_get_contents('https://graph.facebook.com/oauth/access_token?client_id=xxxxclient_idxxx&client_secret=xxxxxxclient_secretxxxx&grant_type=client_credentials');
$tokenarr = str_replace('"','',$access_str);
$tokenarray = explode(":",str_replace(',',':', $tokenarr));
var_dump($tokenarray);  //Request the public posts. 
$json_str = file_get_contents('https://graph.facebook.com/YOUR-PAGE-NAME/feed??fields=attachments&fields=attachments&access_token='.$tokenarray[1]);

//decode json string into array

$data = json_decode($json_str);

foreach ($data as $posts) {
    foreach($posts as $post){
    $postit = (array) json_decode(json_encode($post), True);
    foreach ($postit as $getit) {
    echo '<p>' .$getit['data'][0]['description'].'</p>';
    echo '<img src="'.$getit['data'][0]['media']['image']['src'].'" />';
    echo "</br>-----------</br>";
        }

    }
}

?>

此脚本获取状态文本和图像s

This script get the status text and images

这篇关于PHP - 仅通过Facebook图形从Facebook页面发布数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆