Shila Mosammami
Shila Mosammami

Reputation: 1077

How to edit the photo of a Facebook post in Graph Facebook API?

I want to write a JAVA program to create posts including images, for our clients Facebook pages. using this endpoint https://graph.facebook.com/{{page_id}}/photos and defining the page_access_token, the text message and URL of the photo I can do it. In the following example I have created page_access_token and page_id in Base Environment.

{ "url":"Path_to_the_photo", "message":"The Desired Text" }

As you can see in this photo, the request to create the post is Successful.

Insomnia Request to Create

However I want to be able to edit this photo when it is needed, but I cannot find the endpoint in the documentation Developers Facebook.

I noticed that using https://graph.facebook.com/v19.0/{{page_post_id}} endpoint I can edit the text but not the photo. Does anyone have the idea how I can tackle this?

PS: I have successfully created the application with the full access and the following permissions:

  1. read_insights
  2. pages_manage_cta
  3. pages_show_list
  4. pages_messaging
  5. pages_read_engagement
  6. pages_manage_metadata
  7. pages_read_user_content
  8. pages_manage_ads
  9. pages_manage_posts
  10. pages_manage_engagement

Upvotes: -1

Views: 219

Answers (1)

Shila Mosammami
Shila Mosammami

Reputation: 1077

I found the solution. First we need to send a post request to the endpoint: 1-
https://graph.facebook.com/{{page_id}}/photos

{
  
   "published":false,
   "url":"Path to your photo"
}

on success reading the id. 2- Then another post request to https://graph.facebook.com/{{page_post_id}}

{
  
    "attached_media":[{"media_fbid":"the id you get from the previous request", "message":"media message"}],
   "message":"your probable new message"
}

Upvotes: 0

Related Questions