Search code examples
pythonpython-3.xfacebookfacebook-graph-apipython-3.10

Posting url through Facebook Graph API does not embed the url, just puts it as a url


I am trying to post a URL to wall. Usually, when you post by hand it will load and include a snippet with the title, image, and byline. This does not happen with my API call. Using Python 3.10, with the facebook-sdk.

def post(self, article):
    print(f"\n\n[FacebookPoster] Posting on Facebook:\n\n\"{article.post}\"\n\n")
    self.graph.put_object(parent_object="me", connection_name="feed", message=article.post)

Thanks ahead of time!


Solution

  • Try to use the link parameter to pass your URL.

    If I modify your code, it should give something like:

    def post(self, article):
      print(f"\n\n[FacebookPoster] Posting on Facebook:\n\n{article.post}\n\n")
      self.graph.put_object(parent_object="me", connection_name="feed", message=article.post, link=article.link)