Facebook API/PHP - Is it possible to change a user

2019-01-08 19:25发布

问题:

Is it possible to set/change a user's facebook profile image through the graph API?

I can't find a specific API method, but it is possible to upload an image to a user's album (http://developers.facebook.com/docs/reference/api/photo). Can I set the user's profile image to an image uploaded to their album?

Edit:
Same question asked in reference to REST API
Can I set a users profile image using the Facebook API?

回答1:

No, And here's a comment from a guy at facebook:

The Original Link - you have to press show comments



回答2:

We can do a trick by uploading user’s photo to Facebook via the API then redirect the user to uploaded photo URL with makeprofile=1 added to the list of query strings:

facebook.com/photo.php?pid=xyz&id=abc&makeprofile=1

Check Auto Change Facebook Profile Picture to get PHP example and demo.



回答3:

Currently this is possible by redirecting the user to the mobile profile pic change url, https://m.facebook.com/photo.php?fbid=[fb photo id]&prof&ls=your_photo_permalink

The previous work around, using the facebook.com/photo.php?pid=[fb photo id]&makeprofile=1 url no longer works.



回答4:

To the best of my knowledge and experience: No.



回答5:

See the "Publishing" section here: http://developers.facebook.com/docs/reference/api/photo

Requires the publish_stream permission.

To publish a photo, issue a POST request with the photo file attachment as multipart/form-data.

You can publish an individual photo to a user profile with a POST to http://graph.facebook.com/PROFILE_ID/photos We automatically create an album for your application if it does not already exist. All photos from your application will be published to the same automatically created album.

You can publish a photo to a specific, existing photo album with a POST to http://graph.facebook.com/ALBUM_ID/photos.

The last sentence states you can publish to an existing album, so if you're trying to update the user's profile picture (not sure from the way you stated your question), try getting the album ID for the user, then publishing to that.