【问题标题】:Facebook wallpost image won't render when posting through the Open Graph API通过 Open Graph API 发布时,Facebook 墙贴图片不会呈现
【发布时间】:2012-12-27 21:24:20
【问题描述】:

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

当我将此链接复制并粘贴到 facebook.com 的 Facebook UI 中并以这种方式发布时,墙上的帖子最终看起来像这样:

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

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

产生这个:

如何使用 Facebook API 在我的墙贴中嵌入图片?

【问题讨论】:

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


    【解决方案1】:

    通过附件使用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

    【讨论】:

      猜你喜欢
      • 2012-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多