通過我與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的圖像。所以,我需要弄清楚爲什麼圖像不上牆的出現,但現在我並不需要它,所以也許有一天我會回來這一點。