adeltahir
adeltahir

Reputation: 1097

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',
      image : 'http://someurltoimage.png'
 };

 FB.api(
        "/me/feed",
        "POST",
        {
            "object": {
                "message": body.message,
                "picture": body.image
            }
        },
        function (response) {
          if (response && !response.error) {
              //process when success
          }
        }
    );

But I'm getting following error code.

 error: Object
 code: 100
 error_subcode: 1349125
 message: "Invalid parameter"
 type: "FacebookApiException"

There's no document for this error.

Any advise will be appreciated.

Upvotes: 0

Views: 4947

Answers (1)

Adam Azad
Adam Azad

Reputation: 11297

"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
          }
        }
 );

Upvotes: 3

Related Questions