user984621
user984621

Reputation: 48443

PHP Facebook SDK - how to post friends profile picture to the wall?

I am trying

$attachment = array('message' => "message",
            'name' => 'name',
            'caption' => "caption",
            'link' => 'some URL address',
            'picture' => "https://graph.facebook.com/PROFILE_ID_NUMBER/picture");

But the post on the wall is not posted. When I pick some other image and set up the URL, it works well. This https://graph.facebook.com/PROFILE_ID_NUMBER/picture returns me user's profile picture in the application without any problems, but when I am trying to post it to the wall, then it doesn't work.

So - how could I get the URL of the user's profile picture and post it to the wall?

Upvotes: 1

Views: 411

Answers (2)

Sahil Mittal
Sahil Mittal

Reputation: 20753

Strange, but

'picture' => "https://graph.facebook.com/PROFILE_ID_NUMBER/picture");

should show the PROFILE_ID's pic in the post... I tried and got that, in fact it shows the pic of any user, not necessarily my friend :)

Try using the user's access token with the picture link, might work ..

Upvotes: 1

Smita
Smita

Reputation: 4634

https://graph.facebook.com/PROFILE_ID_NUMBER/picture 

redirects to original image url, which you can get using get_headers function of PHP. something like this you can do:

$headers = get_headers("https://graph.facebook.com/$fbid/picture?type=large");
$image_loc = $headers[5]; //if not work, check at what index actual url is coming though it works for me

and then use this $image_loc url for posting on facebook.

Upvotes: 2

Related Questions