I am using the Facebook API to pull posts into my website and currently I am not able to retrieve the full-sized image from a post, only thumbnails. For posts which are videos, I get a nice large image, but posts with images only display the thumbnail image.
Here is an example response:
[message] => She still likes to come home
[picture] => https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-xfp1/v/t1.0-9/s480x480/1509768_949952475034523_5777855144535809574_n.jpg?oh=296a9975752be40f24a0e32d613328aa&oe=54DCDB3A&__gda__=1426487880_adf80b362906423f8952c92925766989
[link] => https://www.facebook.com/photo.php?fbid=949952475034523&set=o.337363685362&type=1
[icon] => https://fbstatic-a.akamaihd.net/rsrc.php/v2/yz/r/StEh3RhPvjk.gif
[privacy] => stdClass Object
(
[value] =>
)
[type] => photo
[object_id] => 949952475034523
[application] => stdClass Object
(
[name] => Facebook for iPhone
[namespace] => fbiphone
[id] => 6628568379
)
[created_time] => 2014-11-25T18:43:41+0000
[updated_time] => 2014-11-25T18:43:41+0000
Notice how the result in [picture]
is a small image.
Here is the code I am using:
<?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 = "xxxxx";
//App Info, needed for Auth
$app_id = "xxxxxxxxxxx";
$app_secret = "xxxxxxxxxxxxxxxxxxxxxxxxx";
//Retrieve auth token
$authToken = fetchUrl("https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id={$app_id}&client_secret={$app_secret}");
$json_object = fetchUrl("https://graph.facebook.com/{$profile_id}/feed?{$authToken}");
$feedarray = json_decode($json_object);
print_r($feedarray);
?>
Is there a different way to code this that will allow me to retrieve the full-sized image, or is there a way to restructure the URL that is returned to display the larger image?
Thank you.