Facebook API: uploading photos to the wall?

I try to upload a photo to my page (and do it successfully), but not in the way I would like.

This is how I want the photo to display: http://screencast.com/t/wnRFBh1xlf

However, what it actually looks like: http://screencast.com/t/4WblA7s8fyE

Here is the code that I use with cURL to upload a photo (or, rather, a 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 say, I should be able to store the image on my server and host the image source, but I just get an error when I do this.

Here is the code and the error ...

"{" error ": {" message ":" (# 100) the source URL is incorrectly 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 is going wrong here, and I searched all night for this - no luck.

Hope someone can let me know what I should do.

Thanks!

+6
source share
1 answer

You send to /feed connection there, if you want to enlarge the image, you need to upload the photo to one of the user's photo albums (i.e. connection /photos )

+5
source

Source: https://habr.com/ru/post/923605/


All Articles