Facebook PHP抛出异常“(#803)您请求的一些别名不存在”

时间:2013-03-02 22:09:29

标签: php facebook facebook-graph-api

我有一个有效的网页访问令牌,我正在尝试将图片发布到相册(此相册:https://www.facebook.com/media/set/?set=a.333031973457854.77237.323448221082896&type=3) 专辑ID为:333031973457854.77237.323448221082896 但是我收到此错误:OAuthException:(#803)您请求的某些别名不存在:33303197345785477237323448221082896(< - 如您所见,其相册ID) 任何人都可以指导我通过我做错了什么以及我应该如何解决它?谢谢 :) 这是我的代码:

    <?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);
}
?>

1 个答案:

答案 0 :(得分:0)

@MathieuImbert是对的。你需要的部分是第一个整数。

一旦纠正,你可能会得到一个空洞的结果。您也忘了请求publish_stream权限。

此处的官方示例:https://developers.facebook.com/blog/post/498/(案例2)。

此处提供更多信息:https://stackoverflow.com/a/3006901/1515819