2012-01-12 3 views
1

큰 콜라주에서 한 페이지에 모든 프로필 사진을 표시하는 Facebook Graph API를 사용하는 웹 앱을 만들고 있습니다. 내가 API 소비하려면 다음 코드를 사용하고Facebook에서 JSON의 항목 번호 선택 그래프 API

그러나

<!DOCTYPE html> 
<html> 
<head> 
    <style> 
    #images { padding:0; margin:0; overflow: hidden;} 
    #images img { width:200px; height:200px; border:none;} 
    #lists li { display: table;} 
    #lists img { width:200px; height: 200px; } 
    </style> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 
</head> 
<body> 

<div id="profile"></div> 

<script> 

var fburl = "https://graph.facebook.com/733380053/photos?access_token=AAAAAAITEghMBALj91OSuexVZBpZBVH6d4V8VPJtZAKJmm0YzWWUvHe22hxEXZA6MRDqgAwPyCUlqJTufsVbcc2xUw2bEgqQaW3tePkew1QZDZD" 

$.getJSON(fburl, function(data){ 

    var img = data["picture"]; 
    $("#profile").append("<h3>"+ img +"</h3>"); 

}); 

</script> 
</body> 
</html> 

은, 난 그냥 각 사진의 영상 소스를 얻을

하는 HTML의 img를 추가 할 수 있도록하려면 SRC 태그, 다음의 예에서 :

data: [{id:10150556838025864, from:{name:, id:693815863}, tags:{,…},…},…] 
0: {id:10150556838025864, from:{name:, id:693815863}, tags:{,…},…} 
created_time: "2011-12-22T00:31:40+0000" 
from: {name:, id:693815863} 
height: 540 
icon: "http://static.ak.fbcdn.net/rsrc.php/v1/yz/r/StEh3RhPvjk.gif" 
id: "10150556838025864" 
images: [{height:540, width:720,…}, {height:135, width:180,…}, {height:97, width:130,…},…] 
link: "http://www.facebook.com/photo.php?pid=10920894&id=693815863" 
picture: "http://photos-f.ak.fbcdn.net/hphotos-ak-snc7/394974_10150556838025864_693815863_10920894_526292479_s.jpg" 
position: 34 
source: "http://a6.sphotos.ak.fbcdn.net/hphotos-ak-snc7/s720x720/394974_10150556838025864_693815863_10920894_526292479_n.jpg" 
tags: {,…} 
updated_time: "2011-12-22T00:31:45+0000" 
width: 720 

답변

3

이 시도 :

var fburl = "https://graph.facebook.com/733380053/photos?access_token=AAAAAAITEghMBALj91OSuexVZBpZBVH6d4V8VPJtZAKJmm0YzWWUvHe22hxEXZA6MRDqgAwPyCUlqJTufsVbcc2xUw2bEgqQaW3tePkew1QZDZD" 

$.getJSON(fburl, function(data){ 
    //var data = data["data"][0]["picture"]; 
    $.each(data["data"], function() { 
     $a = $("<a></a>").attr("href", this.link); 
     $img = $("<img />").attr("src", this.picture); 
     $a.append($img) 
     $("#profile").append($a); 
    }); 
}); 
답장을

업데이트]

Example fiddle

+0

감사합니다, 작동하지 않았다 죄송합니다. 나는 오류를 얻지도 않는다. 단지 아무 것도하지 않는다. – jcrowson

+1

죄송합니다 - 귀하의 '데이터'액세스 방법이 잘못되었음을 알지 못했습니다. 내 대답을 업데이트했습니다. –

+0

절대 영웅. 고맙습니다! 이것에 추가로 – jcrowson

관련 문제