Search code examples
phpfacebookfacebook-graph-apifacebook-rest-api

Facebook Photo Upload into Album on Fan Page failed


I have written an Application what posts Photos on a FanPage into a Specific Album long time ago.

Now I didn't used for a half year. Now I had to set up the Application again and grant the extended Permissions to the Fan Page (streamm_publish) again. But now I've a Problem, I'm using the old REST API what now gives me the error: An unknown error ocurred with the error code 1.

Then I tried to post throught the Facebook Graph api. I tried to make a call to the Api /pageid/albumid/photos what's not working(Unknown path components) I tried to makea a call to /albumid_from_my_page/photos then the Photos were posted to my profile I tried to upload it to /pageid/photos what is the same as the one above

But the code fpr the REST Api worked well, what's the problem there, and why the new Graph Api isn't working how she should?(BUG?)


Solution

  • To post a photo to an album, this is the code:

    $post_data = array(
        "message" => "My photo caption",
        "source" => '@' . realpath($file)
    );
    $album_id = "XXXXX";
    $facebook->api("/$album_id/photos", 'post', $post_data);
    

    Now I suppose to interact with the page albums you need a page access_token added to your $post_data array, for this check this answer.