skip to Main Content

I’m trying to use the facebook graph api to update the message on a previous post. I have the original post id and a valid never ending user access token. I am getting a “success” message back, but the post message is NOT getting updated.

<CFHTTP METHOD="POST" URL="https://graph.facebook.com/v3.2/#qPost.PostID#?message=#URLEncodedFormat(Message)#&access_token=#AccessToken#" THROWONERROR="YES">
        <cfhttpparam type="header" name="Accept-Encoding" value="*" />
        <cfhttpparam type="header" name="TE" value="deflate;q=0" />     
</CFHTTP>

Success Message:

Success Message

I’m going off the facebook graph details here (i know it says publish_actions permission has been removed), but certainly there has to be a way to update a page post via the graph api.

https://developers.facebook.com/docs/graph-api/reference/v3.2/post#updating

Also when I say I’m trying to update the message, basically the text that is written in the post (see image)

Text I'm Trying To Update

2

Answers


  1. Chosen as BEST ANSWER

    I got this figured out, i was not using the full postid in my request. When the original post was created it sends back a post id, which is a combination of the pageid and the postid (with an underscore in between), it looks like this below, with the first part being the pageid and the one after the underscore being the postid, I was only putting the 2nd part as the postid:

     334797943936653_2003899366299670
    

    It's funny that i would still get a "success" even though I had an invalid postid.


  2. The documentation example states

    POST /v3.2/post-id HTTP/1.1
    Host: graph.facebook.com

    message=This+is+a+test+message

    So message is part of the POST body. But your code sends the message as part of the query string. Solution: Move message and access_token to the body.

    <cfhttp method="POST" url="https://graph.facebook.com/v3.2/#qPost.PostID#" throwOnError="true">
    
        <cfhttpparam type="header" name="Accept-Encoding" value="*" />
        <cfhttpparam type="header" name="TE" value="deflate;q=0" />
    
        <cfhttpparam type="formfield" name="message" value="#Message#" />
        <cfhttpparam type="formfield" name="access_token" value="#AccessToken#" />
    
    </cfhttp>
    

    Encoding is done by cfhttpparam automatically, so keep the readable/desired text in the message variable.

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