2014-09-05 107 views
1

我在上傳照片到Facebook頁面上的相冊時出現問題。上傳照片到頁面是沒有問題的,但是該專輯不起作用。Facebook圖表API:上傳照片到頁面相冊

下面的代碼(從一個例子複製):

<?php 

session_start(); 
require_once 'vendor/facebook/php-sdk-v4/autoload.php'; 

use Facebook\FacebookSession; 
use Facebook\FacebookRedirectLoginHelper; 
use Facebook\FacebookRequest; 
use Facebook\FacebookRequestException; 

// init app with app id (APPID) and secret (SECRET) 
FacebookSession::setDefaultApplication('app_id','app-secret'); 
$scope = array('publish_actions'); 

// login helper with redirect_uri 
$helper = new FacebookRedirectLoginHelper('url'); 

try { 
    $session = $helper->getSessionFromRedirect(); 
} catch(FacebookRequestException $ex) { 
    // When Facebook returns an error 
} catch(Exception $ex) { 
    // When validation fails or other local issues 
} 

// see if we have a session 
if (isset($session)) { 
    /* make the API call */ 
    $request = new FacebookRequest(
     $session, 
     'POST', 
     '/page-id/albums?name=albumname/photos', 
     array (
      'url' => 'url', 
     ) 
    ); 
    $response = $request->execute(); 
    $graphObject = $response->getGraphObject(); 
    /* handle the result */ 
} else { 
    // show login url 
    echo '<a href="' . $helper->getLoginUrl() . '">Login</a>'; 
} 

當我嘗試此我得到的消息: 致命錯誤:未捕獲的異常的Facebook \ FacebookAuthorizationException'與消息「(#100)無效ID對於相冊擁有者「在...

有誰知道最新出錯了嗎?

回答

1

/page-id/albums?name=albumname用於創建帶有該名稱的新專輯。

要將照片發佈到現有相冊,您必須發佈到/{album-id}/photos

有關更多詳細信息,請參見https://developers.facebook.com/docs/graph-api/reference/v2.1/album/photos#publish

+0

好的,謝謝,這是正確的邊緣。在圖形瀏覽器中工作正常,但不是腳本。可能是錯誤的標記。該死的,我討厭那些代幣:D – GoingWild 2014-09-05 11:08:21

相關問題