2014-09-05 113 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

相关问题