Error message while trying to publish a photo to a page

Asked By 0 points N/A Posted on -
qa-featured

Hi all,

I'm trying to publish a photo to a page using the following:

FacebookClient client = new DefaultFacebookClient(destinationAccessToken);
BinaryAttachment attachment = BinaryAttachment.with(imageName, imageInputStream);
Photo photoResponse = client.publish("/me/photos", Photo.class, attachment);

I'm getting the following response:

{
    "error": {
        "message":"An unexpected error has occurred. Please retry your request later.",
        "type":"OAuthException",
        "code":2
    }
}

When I use the same code to publish to a user wall, it works fine.

I've also tried posting to "/{page id}/photos" with the same result.

The destination access token has the manage_pages, photo_upload, publish_actions, and publish_stream permissions amongst others.

What am I doing wrong here?

Please guide me.

Thanks in advance.

SHARE
Answered By 10 points N/A #142222

Error message while trying to publish a photo to a page

qa-featured

Hi Cait,

The error you are getting usually occurs when you try to make a request for the tokens that are specific to a particular page. Failure to such calls usually is proportional to the number of pages which are administered using the account which are meant for the access token. For instance, if you are an administrator of 100 pages, then it is possible to fail more often as you compared to when you type a single page.

That implies that the failure is directly proportional to the response size.

That is because the JSON that is returned can be lengthier for page sets that are too large.

To resolve that issue, you will need to use the link:

http://graph.facebook.com/me/accounts?access_token={admin access token}

Use

http://graph.facebook.com/{page id}?fields=access_token&access_token={admin access token}

That will be able to return an access token that is meant just for that page.

Regards,

Carl

Related Questions