gpt4 book ai didi

通过 Open Graph API 发布时,Facebook 墙贴图片不会呈现

转载 作者:行者123 更新时间:2023-11-30 05:20:22 27 4
gpt4 key购买 nike

当墙贴是通过 Open Graph API 创建时,Facebook 需要一种方法来呈现墙贴中的图像。

当我将此链接复制并粘贴到 facebook.com 的 Facebook 用户界面并以这种方式发布时,墙贴最终看起来像这样:

Successful rendered image in FB wall post

但是,当我尝试使用 Facebook Python 库以编程方式访问我的墙时,使用以下代码,图像不会呈现:

graph = GraphAPI(valid_access_token)
graph.put_wall_post(message='https://s3.amazonaws.com/dotellapptest/review_photos/enlarged/811..OJUzXI76Rw6J2Zj_vZyWNw.png')

产生这个:

unsuccessful Facebook wall post with image

如何使用 Facebook API 将图片嵌入到我的墙帖中?

最佳答案

通过附件使用 link 字段而不是 message 字段

def put_wall_post(self, message, attachment={}, profile_id="me"):
"""Writes a wall post to the given profile's wall.

We default to writing to the authenticated user's wall if no
profile_id is specified.

attachment adds a structured attachment to the status message
being posted to the Wall. It should be a dictionary of the form:

{"name": "Link name"
"link": "http://www.example.com/",
"caption": "{*actor*} posted a new review",
"description": "This is a longer description of the attachment",
"picture": "http://www.example.com/thumbnail.jpg"}

"""
return self.put_object(profile_id, "feed", message=message,
**attachment)

https://github.com/pythonforfacebook/facebook-sdk/blob/master/facebook.py#L142

http://developers.facebook.com/docs/reference/api/user/#links

关于通过 Open Graph API 发布时,Facebook 墙贴图片不会呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14309618/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com