FB 从应用程序上传照片并将其发布到用户的墙上
我有一个关于 Facebook API 的问题。我创建了一个应用程序“屏幕截图提交”,从提交屏幕截图的概念来看,场景是:
- 用户允许我的应用程序后。
- 用户将使用表单选择要在应用程序上上传的文件,然后提交。
我想将所选文件(图像/照片)上传到他/她的相册(从应用程序自动生成)并将文件(图像/照片)发布到他/她的墙上。
$photo_details = array('message'=>$_REQUEST['arttitle'],'source'=> '@' .realpath($_FILES[file]tmp_name])); $facebook->api('/me/photos','POST',$photo_details);
上面的代码将上传照片到自动生成的相册,并返回一个数组,如下所示:
Array([id]=1234567890)
现在,如何使用 php.sdk 和 graph api 将上传的文件(图像/照片)发布到他/她的墙上。
任何帮助将不胜感激。谢谢。
I have a problem regarding the Facebook API. I've created an application "Screenshot Submission", from the concept of submitting the screenshot, the scenario is:
- After the users allows my application.
- The user will select a file to upload on the application using form then submit it.
I want to upload the selected file(image/photo) to his/her album(auto generated from application) and post the file(image/photo) to his/her wall.
$photo_details = array('message'=>$_REQUEST['arttitle'],'source'=> '@' . realpath($_FILES[file]tmp_name])); $facebook->api('/me/photos','POST',$photo_details);
The above code will upload photo to the autogenerated album, and returns an array like:
Array([id]=1234567890)
Now, how can post the uploaded file(image/photo) to his/her wall using php.sdk and graph api.
Any help would be appreciated. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先获取publish_stream的扩展权限。然后以下代码将帮助将照片上传到墙上
First take the extended permission of publish_stream. Then the following code will help to upload the photo to wall
上传照片后,您将返回“照片的object_id”。
使用“object_attachment = '照片的object_id'”在 facebook 墙上发布帖子
curl -F \ "access_token=..." \
-F“消息=等等等等……”
-F "object_attachment=照片的object_id" \
“https://graph.facebook.com/me/feed
更多信息请参见 http://developers.facebook.com/docs/reference/api/user/ posts 部分
object_attachment:用户相册中用作缩略图的现有图片的 Facebook ID。照片的所有者,并且照片不能是邮件附件的一部分。
After uploading the photo, you will get the "object_id of the photo" in return.
Make a post to facebook wall with "object_attachment = 'object_id of the photo'"
curl -F \ "access_token=..." \
-F "message=blah blah...."
-F "object_attachment=object_id of the photo" \
"https://graph.facebook.com/me/feed
more info in http://developers.facebook.com/docs/reference/api/user/ posts section.
object_attachment:Facebook ID for an existing picture in the User's photo albums to use as the thumbnail image. The User must be the owner of the photo, and the photo cannot be part of a message attachment.