2014-09-05 3 views
1

페이스 북 페이지의 앨범에 사진을 업로드하는 데 문제가 있습니다. 페이지에 사진을 업로드해도 아무런 문제가 없지만 앨범에서는 작동하지 않습니다. 치명적인 오류 : :이 때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>'; 
} 

내가 메시지를 얻을 : catch되지 않은 예외 '페이스 북 \ 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

관련 문제