I'm trying to upload a photo to my page's wall (and am doing so successfully) but not the way I'd like to.
Here's how I'd like the photo to show up: http://screencast.com/t/wnRFBh1xlf
However, here's how it actually shows up: http://screencast.com/t/4WblA7s8fyE
Here's the code I'm using with cURL to upload the photo (or rather, link to it)
$img_url = "url";
$page_id = "XXXXX";
$url = "https://graph.facebook.com/$page_id/feed";
$fields = array(
'access_token'=>urlencode("XXXXXXX"),
'message'=>urlencode("Far Cry 3!"),
'picture'=>$img_url
);
So, from what I can tell, I should be able to store the image on my server and post the source of the image over, but I just get an error when I do that.
Here's that code and error...
"{"error":{"message":"(#100) source URL is not properly formatted","type":"OAuthException","code":100}}"
$img_url = 'url';
$img = 'temp_image.jpg';
$contents = file_get_contents($img_url);
file_put_contents($img, $contents);
$path = realpath($img);
//echo $path;
//set POST variables
$page_id = "XXXXXX";
$url = "https://graph.facebook.com/$page_id/feed";
$fields = array(
'access_token'=>urlencode("XXXXXXX"),
'message'=>urlencode("Far Cry 3!"),
'source'=>"@".$path
);
I'm not sure what's going wrong here, and have been searching all night for it - with no luck.
Hopefully somebody can give me a clue as to what I should actually be doing.
Thanks!
Tap in the top right of Facebook, then tap your name. Tap in the bottom right of your cover photo. Tap Upload a photo to upload a photo from your device or Select from album to choose from an album on Facebook.
The first step to upload a file is to create an upload session and obtain a session ID that will be used in each call as you upload the file or check status of the upload. To create a new upload session, make a POST call via the /app/uploads endpoint.
You're posting to the /feed
connection there, if you want the larger image, you need to actually upload the photo to one of the user's photo albums (i.e the /photos
connection)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With