[英]Python script to post a picture with text on a facebook wall
As the title says.正如标题所说。 Is it possible to write a Python script that posts a jpg picture on a facebook wall along with a text string?是否可以编写一个 Python 脚本,将 jpg 图片和文本字符串一起发布到 Facebook 墙上? If it is possible.如果可能的话。 How do I start?我该如何开始?
Best regards.最好的祝福。
"You can do it with Facebook Graph API<\/a>您可以使用Facebook Graph API<\/a>来实现
You can find documentation for posting text and an attachment on a wall here<\/a> .您可以在此处<\/a>找到用于在墙上发布文本和附件的文档。 Make sure to authenticate a user first though.确保首先验证用户身份。 You can find the documentation on the same page您可以在同一页面上找到文档
The code will then look pretty simple:代码看起来很简单:
import facebook
graph = facebook.GraphAPI(access_token='your_token')
attachment = {
'name': 'Link name'
'link': 'http://www.example.com/',
'caption': 'Check out this example',
'description': 'This is a longer description of the attachment',
'picture': 'http://www.example.com/thumbnail.jpg'
}
graph.put_wall_post(message='Check this out...', attachment=attachment)
You can do with POST :您可以使用 POST :
curl -i -X POST "https://graph.facebook.com/ID_PAGE/photos?
url=URL_PICTURE
&message="YOUR_MESSAGE"
&access_token=YOUR_ACCESS_TOKEN"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.