通过我与Python实现的graphapi的工作中,我遇到了这个问题的答案,我问。在某种程度上,可以看到,不可能将图像发布到Facebook墙上(除了使用url链接)。从另一个角度来看,这是非常可能的。你要做的就是将图像添加到相册,添加的图片说明(如果你选择,但它不是必需的),并且图像将被张贴到这张专辑,但它也将出现在Facebook的墙,从而您已将所述图片张贴到墙上。
的图像发布到相册中的代码(我收到的帮助,这从另一个我的做题):
caption = "This will be the description of the image in the album and also the message that appears on the wall" # caption = '' is acceptable if you do not wish to have a message
albumid = '' # this can be the album id of a facebook album or it can be left blank
with open("test.jpg","rb") as image:
posted_image_id = GraphAPI.put_photo(image, caption, albumid)
仅供参考,有用于显示图像的Facebook涂鸦墙的另一种选择,但我无法得到它充分的工作,但我会提到它,以防万一有人想弄清楚我做错了什么
如果你知道已经张贴的图像的facebook imageid,理论上(根据facebook Graph API文档中,你可以使用object_attachment在墙贴上引用所述图像,所以代码看起来像这样:
msg = "This is the message that I want displayed on my wall"
imageid = facebook_image_id #to get this you will have execute a read via the graph api and select the image you want to "reference" on your wall post
GraphAPI.put_object("me", "feed", message=msg,object_attachment=imageid)
这为我工作,除了上也看不到图像,我只看到一个空白区域,但空白区域单击,能够和点击时打开了正确的Facebook的图像。所以,我需要弄清楚为什么图像不上墙的出现,但现在我并不需要它,所以也许有一天我会回来这一点。