在 Facebook“feed”上发布图片从 iPhone 应用程序
我正在使用 ASIHTTPRequest 来处理 Facebook 图形 API。
这是我最近在动态上发布图片的一次。所以如果我有一个
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
url 是 https://graph.facebook.com/me/feed
现在要发布图片,我会执行以下操作:
[request setPostValue:@"My Message" forKey:@"message"];
[request setPostValue:@"somepic.png" forKey:@"picture"];
[request setPostValue:@"Some Name" forKey:@"name"];
[request setPostValue:@"Some description" forKey:@"description];
[request startAsynchronous];
如果您尝试此操作,那么除了发布的图片之外,一切正常。不过,提要上显示了该图片的空白占位符。
I am using ASIHTTPRequest to work on Facebook graph API.
This is the nearest I have gone to posting a picture on the feed. So if I have a
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
The url is https://graph.facebook.com/me/feed
Now to post a picture I do the following:
[request setPostValue:@"My Message" forKey:@"message"];
[request setPostValue:@"somepic.png" forKey:@"picture"];
[request setPostValue:@"Some Name" forKey:@"name"];
[request setPostValue:@"Some description" forKey:@"description];
[request startAsynchronous];
If you try this then everything works fine other than the picture being posted. A blank placeholder for the picture is though show on the feed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只需使用这个小片段将图像作为原始数据上传到磁盘上
Just use this small snippet to upload a image on your disk as raw data
我在 facebook 上找到了这个文档: http://developers.facebook.com/docs/ Reference/api/post
根据本文档,我们无法使用 api 发布驻留在我们机器上的图像。相反,我们必须上传图片,然后提供发布到提要的链接。
但如果您登录 facebook.com,则可以将图像上传到墙上。我相信图形 api 中没有提供此功能。
I found out this documentation on facebook: http://developers.facebook.com/docs/reference/api/post
According to this documentation we can not post an image residing on our machine using the api. Instead we have to upload the pic and then provide the link for posting to the feed.
But uploading an image on to the wall is allowed if you logon to facebook.com. I believe this functionality is not provided in the graph api.
可能值得一看 ShareKit - http://www.getsharekit.com/
他们的演示应用程序发布成功将照片上传到 Facebook 墙上。我相信他们将上传然后发布的过程封装在他们的代码中。
哈特哈,
奥德
It might be worth taking a look at ShareKit - http://www.getsharekit.com/
Their demo app publishes a photo on the Facebook wall successfully. I believe they wrap the upload-then-publish process in their code.
HTH,
Oded