2011-10-02 6 views
0

json을 통해 Facebook 그래프 API를 사용하여 json 데이터를 가져 오려고합니다. 아래 코드를 사용하고 있습니다. 나는 $ .getJSON 함수를 사용하여 JSON 데이터를 얻기 위해 노력하고 있지만, 불을 지르고jquery에서 페이스 북 그래프 API에서 데이터를 가져 오는 방법

NetworkError: 400 Bad Request - https://graph.facebook.com/me/home?access_token=mytoken 
여기

내 코드

<!DOCTYPE HTML> 
<html lang="en"> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"> 
    </script> 
    <script type="text/javascript" src="script/script.js"></script> 
    <script> 
     $(function(){ 
      //$('fb').fbWall(); 
      var url = "https://graph.facebook.com/me/home?access_token=mytoken"; 
      var html = "<ul>"; 
      $.getJSON(url, function(json){ 
       //console.log(json); 
       $.each(json.data, function(i,fb){ 
        html += "<li>" + fb.id + "</li>"; 
       }); 
      }); 
      html += "</ul>"; 

      $('.fb').animate({opacity: 0}, 500, function() { 
       $('.fb').html(html); 
      }); 
      $('.fb').animate({opacity:1}, 500); 
     }); 
    </script> 
    <!-- <link type="text/css" rel="stylesheet" href="styles.css" /> --> 
    <style> 
     .fb { 
      width: 400px; height: 400px; 
      border:1px solid red; 
     } 
    </style> 
    <title>title</title> 
</head> 
<body> 
    <div class="fb"> 

    </div> 
</body> 
</html> 

내가 실수를하고있다에서이 오류를 표시? 당신은 당신이 직접 게시 한 URL로 이동하는 경우

+0

액세스 토큰을 게시하면 모든 사용자에게 계정 세부 정보를 볼 수있는 권한이 부여됩니다. – bkaid

+0

올바른 액세스 토큰이 맞나요? –

+0

예 올바른 액세스 토큰입니다. 어떤 단서? – doforumda

답변

0

, 그것은 오류를 반환 : 그것은 당신이 사용자가 먹이를 읽을 수 read_stream 허가를 묻는 메시지를 표시 할 필요가 의미

{ 
    "error": { 
     "message": "(#606) Queries for multiple source_ids require a non-zero viewer that has granted read_stream permission", 
     "type": "OAuthException" 
    } 
} 

.

+0

자, 토큰을 "XXXXXXXXXXXXXXXXXXXX | JwbAtDcinTgJPpO3I_pcNOdd5gs"형식으로 변경했습니다. 브라우저에서이 링크 "https://graph.facebook.com/ID/feed?access_token=170270366392401|JwbAtDcinTgJPpO3I_pcNOdd5gs"를 사용하면 모든 피드가 표시되지만 내 코드에서 사용하면 아무런 표시도 나타나지 않습니다 맡은 일. 방화범은 GET https://graph.facebook.com/xafarsaleem/feed?access_token=170270366392401|JwbAtDcinTgJPpO3I_pcNOdd5gs \t 200 OK 를 말한다 그러나 그것은 어떤 JSON 데이터를하지 않습니다. – doforumda

관련 문제