facebookfacebook-graph-apiphoto

Created album as a page but can't upload Photos using Graph API


I have searched intensively but I only can find similar topics but no one leads me to a working solution.

As my topic says i created an album as a page using following code.

$page_token = $facebook->api('/'.$page['id'],'GET',array('fields'=> 'access_token'));
$facebook->setAccessToken($page_token['access_token']);

$facebook->setFileUploadSupport(true);

$args = array(
'message'=> 'test album',
'name'=> 'Test Album'
);
$ch = curl_init();
$url = 'https://graph.facebook.com/'.$page['id'].'/albums?access_token='.$page_token['access_token'];//APP_ID.'|'.APP_SECRET;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
$data = curl_exec($ch);

$newAlbum =json_decode($data,true);
$newAlbumID = $newAlbum['id'];

Ok that works so far, I am receiving an album ID. but when I look into the JSON object or look up graph.facebook.com/ALBUM_ID i receive nothing even on the page there is no album.

I have manage_pages read_stream photo_upload publish_stream create_event rsvp_event permissions. Creating an event on the page works pretty fine. What I am doing wrong?

When I try to upload some pictures and create albums it only works for my own profile but I would need it for my page. I don't understand why I am receiving an ID which isn't working when I look it up.

I hope you can help me guys.


Solution

  • Hello everybody I think I have solved my problem. At first it's important to know I have tested nad tried some weeks to finally get the solution.

    As I said I was able to create Events and Questionings on a page. Today I compared creating an album on my profile with creating one on a page and I got to know that this also works fine for both.

    But when I tried to upload a photo into the album or on the page wall it failed with this lovely exception: "An unexpected error has occurred. Please retry your request later"

    Today I tried to remove some permissions. as you can see below

    OLD --> define('PERMISSIONS', 'offline_access read_stream photo_upload user_photos friends_photos user_photo_video_tags publish_stream read_friendlists ads_management create_event user_online_presence friends_online_presence rsvp_event manage_pages');

    NEW --> define('PERMISSIONS', 'photo_upload user_photos friends_photos publish_stream create_event manage_pages');

    and now it works!