Skip to content Skip to sidebar Skip to footer

Posting To Facebook Wall Using Graph Api

I'm trying to post a text with image to facebook wall using graph api. I'm using following code snippet for this. var body = { message : 'this is a test message', imag

Solution 1:

"I'm trying to post a text with image to facebook wall using graph api."

  • You are using /feed, to upload a photo you have to use /photos call
  • You are sending an invalid parameter object which contains your parameters, to Facebook, the API doesn't know that your parameter Object is an object (I know, too many objects here, in another way, you're sending an object within an object

To solve all this, replace me/feed with me/photos and the 3rd argument (your object) with the body

var body = {
      message : 'this is a test message',
      url: 'http://someurltoimage.png'
 };

 FB.api("/me/photos",
        "POST",
        body,
        function (response) {
          if (response && !response.error) {
              //process when success
          }
        }
 );

Post a Comment for "Posting To Facebook Wall Using Graph Api"