Carga de archivos en el álbum de la página de la aplicación con Graph API

I've run over all related topic, but couldn' find the answer for this: Is it possible to store an apps photos only in its own page album? Please mind that every user should upload photos to the same album. I've seen that apps can create album at the users/pages profile, but it would be nicer to store everything in one place.
Estoy recibiendo el siguiente error:

Uncaught OAuthException: (#120) Invalid album id (base_facebook.php line 1038)


public function setPageToken($userId = 'MY_USER_ID',
        $pageId = 'APP_PAGE_ID')
    // get logged in all page
    $args = array
        'fileds'    => 'id,access_token',
        'scope'     => 'manage_pages,publish_stream'
    $accounts = $this->api('/'.$userId.'/accounts','get',$args);
    // fetch the desired page access token
    foreach($accounts['data'] as $k => $v)
        if($v['id'] == $pageId)
            $token = $v['access_token'];
    return $token;


  1. my app ID is not equal to my apps page ID
  2. $accounts return value is empty

preguntado el 30 de enero de 12 a las 19:01

1 Respuestas

Theoretically, here is what you need to do:

  1. Get Page access token with permissions to upload photos.
  2. Hard-code or otherwise store the latter access token.
  3. Next time user uploads a photo using your HTML form you will need to use the latter access token to upload the photo to the page album.

Note, that theoretically, this doesn't require to authorise the user who is uploading the photo. However, if the question is whether you can upload a photo to a third-party page on user's behalf – you cannot.

Furthermore, note that if you are using Facebook PHP SDK, the default Token de acceso will be that of the presently active session (the user). Therefore you will need to manually change it to the Page access token or issue cURL request.

$ch = curl_init();
$url = "" . $album_id . "/photos?access_token=" . $access_token;
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);
$retdata = curl_exec($ch);

upload photo to page timeline Facebook SDK

contestado el 23 de mayo de 17 a las 13:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.