2012-05-07 5 views
0

이 코드를 사용하고 있지만 빈 데이터 배열을 반환합니다. 내 access_token에 모든 권한이 있습니다.
PAGE_ID을 (를) 알고 있습니다. 이제이 페이지에서 이벤트를 가져와야합니다.
감사Facebook에서 페이지 이벤트를 가져 오는 방법은 무엇입니까?

그것은 당신의 코드에서 분명하지 않다
<div id="fb-root"></div> 
    <script> 
     window.fbAsyncInit = function() { 
     FB.init({ 
      appId  : APP_ID, // App ID 
      status  : true, // check login status 
      cookie  : true, // enable cookies to allow the server to access the session 
      xfbml  : true // parse XFBML 
     }); 
     // Additional initialization code here 
     }; 

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

     var interval = setInterval(function() { 
      if (typeof FB != 'undefined') { 
       clearInterval(interval); 
       FB.api('/' + PAGE_ID +'/events?access_token=' + ACCESS_TOKEN, function(response) { 
        //do something with response 
       }); 
      } 
     }, 20); 
    </script> 

답변

1

내 첫 access_token은 틀렸다. (어쩌면 단지 테스트 모드에 대한) 때문에 나는이 access_token에 의해 이벤트를 얻을 수 없습니다. http://developers.facebook.com/docs/authentication/applications/
작성되었습니다 :

앱 액세스 토큰은 일반적으로 만료되지 않습니다. 일단 생성되면 무기한 유효합니다. https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&grant_type=client_credentials

내가 HTTP GET을 사용하여 access_token이있어, 내가 페이스 북 페이지에서 이벤트를 받기 access_token은에 의해 : https://graph.facebook.com/PAGE_ID/events

+0

아무도이 페이지에서 작동하지 않는 이유를 알고 있습니까? https://www.facebook.com/pages/La-CALLE-Jam-Sessions/404870736262643?id=404870736262643&sk=events – surfealokesea

1

당신이 access_token은을 얻는 방법 - 당신이 이벤트를 검색해야하는 페이지 \ 계정의 액세스 토큰을 사용하고 있습니까? 페이지 이벤트에 대해 내가이 기술을 선택했는지 여부는 잘 모르겠습니다. 사용자 계정을 반복하여 문제의 페이지에 대한 액세스 토큰을 얻는 것입니다. 내가 http://developers.facebook.com/tools/explorer/에서 얻을 내 APP이 (PHP)과 같은 뭔가

$accounts = $facebook->api('/me/accounts'); 
foreach($accounts['data'] as $account){ 
    if($account['id'] == $page_id){ 
     $page_access_token = $account['access_token']; 
    } 
} 
+0

을 내가 조금 오해를 해요
는 HTTP가 GET 수행, 앱 액세스 토큰을 구하십시오. 어쩌면 내가 틀렸어. 이 페이지와 같은 이벤트 (예 : facebook.com/ExamplePage)를 가져와야합니다. 내 페이지가 아니지만이 페이지의 이벤트는 공개됩니다. 그런 다음 그래프 API 탐색기를 통해 새 ExampleApp를 만들었습니다. 액세스 토큰을 얻습니다. 나는 ExampleApp와 ExamplePage를 어떻게 관련 지을 수 없다. ExampleApp에 의해 취해진 access_token이 ExamplePage에 유효하지 않은 것 같습니다. – Ikrom

+1

내 코드가 이벤트를 읽는 데 과도 할 수도 있습니다. 나중에 다른 이벤트 관리를 위해 해당 page_access_token을 사용하고있는 것으로 나타났습니다. 그리고 [페이지 문서] (https://developers.facebook.com/docs/reference/api/page/)에 따르면 모든 유효한 access_token이 이벤트 연결을 확보하기에 충분해야합니다. –

관련 문제