GraphAPIError: (#324) 需要上传文件
我正在尝试使用 python sdk 上传图片:
代码:
graph = facebook.GraphAPI(self.current_user.access_token)
graph.put_object("me", "photos", name = "test", message = raw_picture_data)
但收到错误“GraphAPIError:(#324) 需要上传文件”
。我不认为这是权限问题,因为我已请求 perms="user_photos,friends_photos,publish_stream"。有谁知道这个错误意味着什么以及如何解决它?
I'm trying to upload a picture with the python sdk:
Code:
graph = facebook.GraphAPI(self.current_user.access_token)
graph.put_object("me", "photos", name = "test", message = raw_picture_data)
But I get the error "GraphAPIError: (#324) Requires upload file"
. I don't think its a permissions issue as I've requested perms="user_photos,friends_photos,publish_stream". Does anyone know what this error means and how to resolve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我使用这个库对图像进行编码: http://atlee.ca/software/poster/
添加这个到 facebook.py:
将照片作为类似对象的文件来调用该函数:
put_photo 方法已由某人(我忘记了是谁)提交,作为建议添加到 API 的函数,但它对我不起作用,直到我使用海报对图像进行编码。
希望这有帮助。
I used this library to encode the image: http://atlee.ca/software/poster/
Add this to facebook.py:
Call the function with the photo as a file like object:
The put_photo method has been submitted by someone (I forget who) as proposed a function to add to the API but it didn't work for me till I used poster to encode the image.
Hope this helps.
刚刚与类似的错误作了一些斗争。我没有使用 SDK,只是使用了 graphapi 的 POST。对我来说,当我没有向发送到 Facebook 的“表单”中的文件上传字段提供文件名时,就会发生此错误。
这是我的代码(海报 - http://pypi.python.org/pypi/poster/ 0.8.1)
Just battled with a similar error a bit. I did not use the SDK but just a POST to the graphapi. For me, this error happened when i didnt supply a filename to the file upload field in the "form" sent to facebook.
This is my code (poster - http://pypi.python.org/pypi/poster/0.8.1)