Facebook API/PHP - 是否可以通过 FB Graph API 更改用户的个人资料图片?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4370669/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 12:51:07  来源:igfitidea点击:

Facebook API/PHP - Is it possible to change a user's profile image via FB Graph API?

phpfacebook-graph-api

提问by John Himmelman

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

是否可以通过图形 API 设置/更改用户的 Facebook 个人资料图片?

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?

我找不到特定的 API 方法,但可以将图像上传到用户的相册 ( http://developers.facebook.com/docs/reference/api/photo)。我可以将用户的个人资料图片设置为上传到他们相册的图片吗?

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

编辑:
参考 REST API 提出的相同问题
我可以使用 Facebook API 设置用户个人资料图片吗?

回答by t0mgs

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

不,这是 facebook 上的一个人的评论:

This Is A A Facebook Developer!

这是 AA Facebook 开发者!

The Original Link- you have to press show comments

原始链接- 你必须按显示评论

回答by Hoan

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=1added to the list of query strings:

我们可以通过 API 将用户的照片上传到 Facebook,然后将用户重定向到上传的照片 URL,makeprofile=1并将其添加到查询字符串列表中:

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

Check Auto Change Facebook Profile Pictureto get PHP example and demo.

检查自动更改 Facebook 个人资料图片以获取 PHP 示例和演示。

回答by ggtsu

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

目前,这可以通过将用户重定向到移动配置文件 pic 更改 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=1url no longer works.

以前的解决方法,使用facebook.com/photo.php?pid=[fb photo id]&makeprofile=1url 不再有效。

回答by Peter Bailey

To the best of my knowledge and experience: No.

据我所知和经验:没有。

回答by Matt Huggins

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

请参阅此处的“发布”部分:http: //developers.facebook.com/docs/reference/api/photo

Requires the publish_streampermission.

To publish a photo, issue a POSTrequest 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/photosWe 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.

需要publish_stream许可。

要发布照片,请发出POST带有照片文件附件的请求multipart/form-data

您可以使用 POST 将单张照片发布到用户个人资料,http://graph.facebook.com/PROFILE_ID/photos如果相册尚不存在, 我们会自动为您的应用程序创建相册。您应用程序中的所有照片都将发布到同一个自动创建的相册中。

您可以使用 POST 将照片发布到特定的现有相册 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.

最后一句说明您可以发布到现有相册,因此如果您尝试更新用户的个人资料图片(根据您提出问题的方式不确定),请尝试获取用户的相册 ID,然后发布到该相册。