最新帖子Facebook页面整合到网站

<?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 />";
}

  ?>

When I try to run my code with my details (fully open page), I get an output of

Warning: Invalid argument supplied for foreach() in /home/xxxxxxxxx/public_html/includes/footer.php on line 52

When I use the code below it prints bool(false).

$feedData = curl_exec($ch);
var_dump($feedData); die();

I have worked out that the fetchUrl's are not working and I have tried many different others but none seem to work...

Any ideas?