1

I have a valid page access token, and I am trying to post a picture to an album (this album: https://www.facebook.com/media/set/?set=a.333031973457854.77237.323448221082896&type=3) The album ID is then: 333031973457854.77237.323448221082896 But I get this error: OAuthException: (#803) Some of the aliases you requested do not exist: 33303197345785477237323448221082896 (<-- As you see its the album ID) Could anyone guide me thru what I have done wrong and how I should fix it? Thanks :) Here is my code:

    <?php
$fbconfig['appid' ]    = "172098812914132";
$fbconfig['secret']    = "XXXXXXXXXXXXXXXXX";
$fbconfig['pageid']    = "323448221082896";
$fbconfig['token1']    = "XXXXXXXXXXXXXXXX";
$fbconfig['token2']    = "XXXXXXXXXXXX";
$fbconfig['my_ulr']    = 'http://'.$_SERVER['SERVER_NAME'];
$albumid = '33303197345785477237323448221082896';
require_once('../scripts/facebook.php');
$facebook = new Facebook(array(
  'appId'  => $fbconfig['appid'],
  'secret' => $fbconfig['secret'],
));

$pageid = $fbconfig['pageid'];
$imagesDir = 'images/';
$images = glob($imagesDir . '*.{jpg,jpeg,png,gif,JPG,JPEG,PNG,GIF}', GLOB_BRACE);
$randomImage = $images[array_rand($images)];
printf("Trying to upload: " . $randomImage . "\n"); // The path to the random image.
try
{
  //  $page_info = $facebook->api("/$pageid?fields=access_token");  
// Album ID 33303197345785477237323448221082896
$args = array(
    'access_token'  => $fbconfig['token2'],
    'source' => 'www.gorillalol.com/i/' . $randomImage,
    );          
    $post_id = $facebook->api("/" . $albumid . "/photos","post",$args);
    unlink($randomImage); // Deletes the file, so it can't get reposted.
    printf("Successful Image Upload :)");
} 
catch (FacebookApiException $e)
{
    printf("Failed. :p");
    printf($e);
}
?>
Stéphane Bruckert
  • 21,706
  • 14
  • 92
  • 130
Alex Noble
  • 95
  • 1
  • 6

1 Answers1

0

@MathieuImbert is right. The part you need is the first integer.

Once this corrected, you'll probably get an empty result. You also forgot to request the publish_stream permission.

Official example here: https://developers.facebook.com/blog/post/498/ (scenario 2 in your case).

More information here: https://stackoverflow.com/a/3006901/1515819

Community
  • 1
  • 1
Stéphane Bruckert
  • 21,706
  • 14
  • 92
  • 130