Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook wallpost image won't render when posting through the Open Graph API

Need a way for Facebook to render images in a wallpost when the wall post is made through the Open Graph API.

When I copy and paste this link into the Facebook UI at facebook.com, and post it that way, the wall post ends up looking like this:

Successful rendered image in FB wall post

But, when I try to access my wall programmatically using the Facebook Python library, using the below code, the image does not render:

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

Yields this:

unsuccessful Facebook wall post with image

How can I use the Facebook API to embed an image in my wall post?

like image 811
Clay Wardell Avatar asked Jan 13 '13 23:01

Clay Wardell


1 Answers

Use the link field not the message field via an attachment

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

like image 143
phwd Avatar answered Sep 29 '22 03:09

phwd