2011-05-11 6 views
3

내 벽에 메시지를 게시하는 데 사용되는 간단한 PHP 페이지가 있습니다.Facebook OAuthException : 응용 프로그램 유효성 검사 오류 :

"read_stream"및 "publish_stream"권한이있는 offline_access 토큰을 받았습니다.

define('FB_APIKEY', 'MY_APP_KEY'); 

define('FB_SECRET', 'MY_APP_SECRET'); 

define('FB_SESSION', 'MY_OFFLINE_TOKEN'); 

require_once('facebook.php'); 

try { 
    $facebook = new Facebook(FB_APIKEY, FB_SECRET); 

    $facebook->api_client->session_key = FB_SESSION; 

    $attachment = array(
     'message' => 'some meesgae', 
     'name' => 'This is my demo Facebook application!', 
     'caption' => "Caption of the Post", 
     'link' => 'mylink.com', 
     'description' => 'this is a description', 
     'actions' => array(array(
        'name' => 'Get Search', 
        'link' => 'google.com' 
       )) 
    ); 

    $result = $facebook->api('/me/feed?access_token=' . FB_SESSION, 
       'post', 
       $attachment); 

    var_dump($result); 

} catch(Exception $e) { 
    echo $e; 
} 

실행할 때 "OAuthException : Error validating application"이 표시됩니다.

오프라인 토큰이 좋음을 확인했습니다. https://graph.facebook.com/me?access_token=[MY_OFFLINE_TOKEN]로 이동하면 내 공개 프로필이 JSON 형식으로 올바르게 반환됩니다.

그래서 저는 API 호출에 문제가 있다고 생각하고 있습니다.하지만 내 인생에 대해서는 알아낼 수 없습니다. 나는 지난 이틀 동안이 문제와 씨름하고있다. 누군가 제발 도와 줄 수 있어요! :(

답변

4

현재 APP ID가 그리고이 같은 전화를 걸하지 않습니다...

require_once('facebook.php'); 

$facebook = new Facebook(array(
    'appId' => 'APP_ID', 
    'secret' => 'APP_SECRET', 
    'cookie' => true 
)); 

try { 
    $attachment = array(
     'message' => 'some meesgae', 
     'name' => 'This is my demo Facebook application!', 
     'caption' => "Caption of the Post", 
     'link' => 'mylink.com', 
     'description' => 'this is a description', 
     'actions' => array(array(
      'name' => 'Get Search', 
      'link' => 'google.com' 
      )) 
    ); 

    $attachment['access_token'] = $offline_access_token; // add it to the array 

    $result = $facebook->api('/me/feed', 'POST', $attachment); 

    var_dump($result); 

} catch(Exception $e) { 
    // error_log($e); // should use something like this when in production 
    echo $e; 
} 

테스트되지 않은,하지만 작동합니다 그렇지 않은 경우 알려줘

+0

를 이는처럼 일 감사합니다, 고마워요, 고마워요 !!!! – PFrank

+0

페이지의 이름을 올리는 방법을 알고 있습니까? – opHASnoNAME

관련 문제