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

标签 facebook image facebook-graph-api facebook-wall

当墙贴是通过 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/

相关文章:

ios - LibGDX RoboVM Robopods Facebook 登录错误

facebook - FB 未定义

java - Facebook 应用程序的测试帐户(例如 JUnit 测试手册)

php - 将 Codeigniter 项目连接到 Facebook API 的最佳方式是什么?

Perl facebook 图形给出无法获取访问 token : Bad Request at/usr/local/share/perl/5. 10.1/Facebook/Graph/AccessToken/Response.pm

html - 根据分辨率制作图像比例

html - 图片不显示在网站上但本地不显示?

image - .tga 图像 : Value that should be represented by a word is only correct if I read the first half word

javascript - 打开 'feed' 对话框时如何在没有访问 token 的情况下获取用户的名字?

Facebook 图形 API 不尊重别名