skip to Main Content

I am trying to make a post to a Facebook page using the Graph API that includes an image. I have successfully done it with a two step process:

  1. Post to ‘https://graph.facebook.com/PAGE_ID/photos?url=IMAGE_URL&access_token=ACCESS_TOKEN
  2. Taking the image id from the return data from the post and making another post to ‘https://graph.facebook.com/PAGE_ID/feed?published=true&message=MESSAGE_TEXT&object_attachment=IMAGE_ID&fields=permalink_url&access_token=ACCESS_TOKEN

However, when I do that, FB posts the image to the page first and then posts the message with the image in it. Not ideal; I only want a single post with message and image.

I then tried keeping the image unpublished (adding &published=false to my image post). That worked to keep the image from posting on the page and I got an OK message with the image id back from FB. However, I received an error code (1 – “An unknown error occurred”) from the FB API when I went to post the message with image.

I also tried to keep the image unpublished and flag that as temporary (adding &published=false&temporary=true to my image post) with the same result.

Anyone know how to post a message with image to a page without first posting the image to the FB page?

2

Answers


  1. You can add a caption to your image post.

    Or add the image as form data while creating the post.

    Which Framework do you use?

    Login or Signup to reply.
  2. The no_story parameter can be used to suppress the automatic creation of a feed story for the photo upload.

    https://developers.facebook.com/docs/graph-api/reference/photo#Creating:

    no_story
    boolean
    If set to true, this will suppress the News Feed story that is automatically generated on a profile when people upload a photo using your app. Useful for adding old photos where you may not want to generate a story

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search