FB开发者:Uncaught OAuthException:(#120)无效的专辑ID

时间:2013-11-20 11:53:33

标签: php facebook facebook-graph-api

我正在尝试在粉丝页面上发布照片,但我收到了此错误:

  

致命错误:未捕获OAuthException:(#120)第1264行/home/eyikmdnu/public_html/jack/facebook-sdk/base_facebook.php中引发的无效相册ID

这是页面的代码(obv,令牌,秘密等不是“原始”

require_once("../facebook-sdk/facebook.php");

    define("APP_ID", "*****");
    define("APP_SECRET", "********");

    $fanpage_token = "*******";

    $user_access_token = "********";    


    $config = array(
      'appId' => APP_ID,
      'secret' => APP_SECRET,
      'fileUpload' => true // optional
     );
  $facebook = new Facebook($config);

    //pagina = 358226040977616
    //album id =  402459486554271


  //$access_token = $_POST['access_token'];
  //echo $access_token;

  $facebook->setAccessToken($fanpage_token); 
  echo "Access Token Settato <br>\n";

  $facebook->setFileUploadSupport(true);
  echo "setFileUploadSupport(true) settato <br>\n";

  $img_url = "images/jack.png";
  //$img_url = $_POST['url'];
  echo "$img_url = $img_url <br>\n";

  $page_id = "358226040977616";
  $album_id = "402459486554271";
  echo "Page id: $page_id <br>\n";
  echo "Album id: $album_id <br>\n";

  $real_img_url = realpath($img_url);
  echo "Real img url: $real_img_url <br>\n";

  $args = array(
    'message' => 'message to write in legend',
    'image' => "@" . $img_url,
    'aid' => $album_id,
    'no_story' => 1,
    'access_token' => $fanpage_token
    );

  echo "<br>\n";
  print_r($args);
  echo "<br>\n";

  $photo = $facebook->api("/".$album_id."/photos", 'post', $args);
  print_r($photo);

需要帮助! :o

1 个答案:

答案 0 :(得分:1)

我解决了,问题是我应该使用页面的access_token,这不是静态的,我必须查看我的/ profile / accounts

$params = array('access_token' => $access_token);
$accounts = $facebook->api('/giacomo.torricelli/accounts', 'GET', $params);

foreach($accounts['data'] as $account) {
    if( $account['id'] == $fanpage || $account['name'] == $fanpage ){
        $fanpage_token = $account['access_token'];
    }
}

由于