Php 最新发布的Facebook页面集成到网站
当我使用下面的代码时,它会打印bool(false) 我发现fetchUrl不起作用,我尝试了许多其他的方法,但似乎都不起作用Php 最新发布的Facebook页面集成到网站,php,html,facebook,facebook-graph-api,curl,Php,Html,Facebook,Facebook Graph Api,Curl,当我使用下面的代码时,它会打印bool(false) 我发现fetchUrl不起作用,我尝试了许多其他的方法,但似乎都不起作用 有什么想法吗?只是检查一下,你确实做了var\u dump($feedData)而不是var\u dump($data),对吗?哎呀!我用正确的代码得到bool(false):)那么有什么想法吗?我以前可以用RSS来做,但它已经不见了,而且更新速度很慢:( <?php function fetchUrl($url){ $ch = curl_init();
有什么想法吗?只是检查一下,你确实做了
var\u dump($feedData)代码>而不是var\u dump($data)代码>,对吗?哎呀!我用正确的代码得到bool(false):)那么有什么想法吗?我以前可以用RSS来做,但它已经不见了,而且更新速度很慢:(
<?php
function fetchUrl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$feedData = curl_exec($ch);
curl_close($ch);
return $feedData;
}
$profile_id = "xxxxxxxxxxxxx";
//App Info, needed for Auth
$app_id = "xxxxxxxxxxxx";
$app_secret = "xxxxxxxxxxx";
$authToken = fetchUrl("https://graph.facebook.com/oauth/access_token?type=client_cred&client_id={$app_id}&client_secret={$app_secret}");
$json_object = fetchUrl("https://graph.facebook.com/{$profile_id}/posts?{$authToken}");
$feedarray = json_decode($json_object);
echo $json_object;
foreach ( $feedarray->data as $feed_data )
{
echo "<h2>{$feed_data->name}</h2><br />";
echo "{$feed_data->message}<br /><br />";
}
?>
Warning: Invalid argument supplied for foreach() in /home/xxxxxxxxx/public_html/includes/footer.php on line 52
$feedData = curl_exec($ch);
var_dump($feedData); die();