2012-06-14 2 views
0

내 앱의 승인을 얻기 위해 페이스 북 Grahp에 대한 작업을 게시하기 위해 노력하고있어 .. 오류 액세스 토큰을 얻는 방법 :자바 스크립트 API를 사용하여 동적으로

당신은 적어도 하나 개의 조치를 게시해야합니다 작업을 게시를 이 작업 유형을 사용하여 타임 라인에 추가하십시오.

은 그래서 조치를 (필자는 코드 형태를 가지고 : 그래프 API)를 게시 할 수있는 간단한 페이지를 생성하고이 하나 :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="de-DE" xmlns:fb="https://www.facebook.com/2008/fbml"> 

<head prefix="og: http://ogp.me/ns# fashion_econtest: http://ogp.me/ns/apps/fashion_econtest#"> 

    <title>Fashion</title> 
    <meta property="fb:app_id" content="MyAppId" /> 
    <meta property="og:type" content="fashion:contest" /> 
    <meta property="og:title" content="eContest" /> 
    <meta property="og:image" content="The Image" /> 
    <meta property="og:description" content="Registrati e vinci cli accessori più fashion dell&#039;anno!" /> 
    <meta property="og:url" content="MyURL"> 

    <script type="text/javascript"> 
     function postSubscribe(){ 
      FB.api(
      '/me/fashion:subscribe', 
      'post', 
      {share:'MyUrl'}, 
      function(response){ 
       if(!response){ 
        alert('Error'); 
       }else if(response.error) { 
        alert(response.error.message); 
       }else{ 
        alert('Subscribe was successful! Action ID: ' + response.id); 
       } 
      }); 
     } 
    </script> 
</head> 
<body> 
    <div id="fb-root"></div> 
    <script> 
     window.fbAsyncInit = function(){ 
      FB.init({ 
       appId  : 'MyAppId', // App ID 
       status  : true, // check login status 
       cookie  : true, // enable cookies to allow the server to access the session 
       xfbml  : true // parse XFBML 
      }); 
     }; 

     // Load the SDK Asynchronously 
     (function(d){ 
      var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} 
      js = d.createElement('script'); js.id = id; js.async = true; 
      js.src = "//connect.facebook.net/it_IT/all.js"; 
      d.getElementsByTagName('head')[0].appendChild(js); 
     }(document)); 
    </script> 

    <h3>Fashion</h3> 
    <p> 
     <img title="Vinci i premi più Fashion!" src="http://xxxxxx.de/img/yyyyyy.jpg" width="550"/> 
    </p> 

    <br> 
    <form> 
     <input type="button" value="Subscribe" onclick="postSubscribe();" /> 
    </form> 
</body> 

하지만 요청을 전송하면, 내가 얻을 follwonig 오류 :

An active access token must be used to query information about the current user.

나는 동적으로 자바 스크립트 FB-API에 액세스 토큰을 얻을이 작업을 할 수 있습니까?

많은 분들께 감사드립니다. 아민

답변

0

먼저 FB.login을 호출하고 적절한 권한 (publish_actions)을 요청하십시오.

(또는 한 번 당신이거야 단지가해야 할 일에 대한 스크립트를 작성하는 대신 그래프 API 탐색기를 사용하여 모든 일을.)

관련 문제