I'm having a strange problem with the graph API, the below code used to work for me adding a post to a users news feed with a thumbnail of the attached photo (referenced in 'object_attachement' parameter).
However now the post is created as expected however the thumbnail is empty. The photo_id I am using exists in the user's photo collection.
$photo_ID = "3415678920211";//Valid Facebook Photo ID...
$facebook = new Facebook($config);
$attachment = array(
'access_token' => $user_token,
'message' => "Test Message",
'caption' => "THis is a Caption",
'name' => "Test Name",
'description' => "This is a description",
'link' => 'http://url.com/',
'object_attachment' => $photo_id,
);
$response = $facebook->api("/".$userID."/feed/", 'POST', $attachment);
Am I doing something wrong? I am sure this did use to work and wonder if something changed in the API underneath me.
[Update] I noticed that this seems to happen when I specify both link & object_attachment in the same POST. If I remove the link param from the above then I get a slightly better update however this isn't great as the main reason I want this post to exist is for the addition of the link.
You are posting to the feed. You should post to the LINK instead.
Post the link to the picture to the link feed, and you should be fine.
https://developers.facebook.com/docs/reference/api/link/
I will post an example in a tick.
---- Later ----
Hmmmm, well the link option isn't satisfactory. You get a thumbnail of the picture, and you can click it to see the picture in full, but its very ugly. I really don't think that is what you are after.
So I did some more experiments, and kept coming up against that CDN error you mentioned. So I googled it and found the following:
Serving Images in Stream Stories Jun 18, 2010 3:21pm
We no longer allow stream stories to contain images that are hosted on the fbcdn.net domain. The images associated with these URLs aren't always optimized for stream stories and occasionally resulted in errors, leading to a poor user experience. Make sure your stream attachments don't reference images with this domain. You should host the images locally.
So there you have it, according to Facebook, you can no longer do what you want to do.
I think the
'object_attachment'=>$photo_id
won't work any more. You should change it to'picture'=>$photo_url
You can find more Here
I am assuming user gave the permission for user_photos / friends_photos. Since you have the photo_id, you may try this.
ADDED
You need to store the image some where locally ,in a local server . due to this article
you have to permission pubish_stream on your app and then try this using curl:-