Sven de Bie
Sven de Bie

Reputation: 43

(#120) Invalid album id

I currently have the following code. But the graph api still return (#120) Invalid album id. If i look at $facebook_album or https://developers.facebook.com/tools/explorer/248099655226775/?method=GET&path=213152142082066 it shows an album. So the album does exist.

public function save_facebook(){

    Site::debug();

    $album_item = new Foto_Album_Item($this['navigatie_obj']['parent_id']);

    // File upload activeren
    Site::$facebook->setFileUploadSupport(true);

    // Facebook album ophalen
    $facebook_album = Site::$facebook->api('/'.$album_item['facebook_id']);

    // Facebook als gebruiker gebruiken ipv als applicatie
    Site::$facebook->setAccessToken( Facebook::$user_access_token );
    $user_id = Site::$facebook->getUser();

    $facebook_options = array(
        'source' => '@'.realpath(Site::$serverpath['album'].$this['navigatie_obj']['parent_id'].'/'.$this['bestand']),
        'access_token' => Facebook::$user_access_token,
    );

    $request_method = '/'.$album_item['facebook_id'].'/photos';

    $return = false;
    try {
        $result = Site::$facebook->api($request_method,'POST',$facebook_options);           
        $options = array('facebook_id' => $facebook_id ? $this['facebook_id'] : $result['id']);     
        $return = parent::save($options);
    } catch(Exception $e){
        Log::error($e,__FILE__,__LINE__);
    }

    return $return;

}

Upvotes: 4

Views: 3018

Answers (1)

Anatoly Lubarsky
Anatoly Lubarsky

Reputation: 3036

to be able to upload to an album that belongs to a page there are several things you should check (or change):

  1. user should be a page admin.
  2. user should grant 'manage_pages' permission to the app.
  3. app should call graph/me/accounts and iterate available accounts to get access_token for the page.
  4. then you proceed to '/album_object_id/photos' with upload.

error message you get is obviously misleading

hope this helps

Upvotes: 4

Related Questions