Post picture on Facebook



    Social Media Posting

    Put a picture that shows on the feed of a specific page.

    To get your token, see

    For this recipe, we store the facebook page id and the token as environment variable.

    import os
    import facebook
    def post_facebook(message, image_path):
      PAGE_ID = os.environ["FACEBOOK_PAGE_ID"]
       link = ""
       with open(image_path, 'rb') as picture_file:
        graph = facebook.GraphAPI(PAGE_ACCESS_TOKEN)
        photo_put = graph.put_photo(image=picture_file, message=message, published=True, link=link)
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.