2016-08-03 85 views
0

需要一些幫助,以使用Facebook圖形API從文章中獲取正常或更大的圖像,目前它只能在對象中提供130 x 130像素的圖像。Facebook圖形API獲取原始圖片大小不起作用

function fbFetch() { 
 

 
    var access_token = ""; 
 
    var url = "https://graph.facebook.com/?ids=intel&fields=posts.limit(5){message,created_time,picture.type(normal)}&access_token=' + access_token; 
 

 
    $.getJSON(url, function(response) { 
 

 
     var messages = []; 
 

 
     Object.getOwnPropertyNames(response).forEach(function(page, idx, array) { 
 
      response[page].posts.data.forEach(function(post, idx, array) { 
 
       messages.push(post); 
 
      }); 
 
     }); 
 

 
     function compare(a, b) { 
 
      if (a.created_time < b.created_time) 
 
       return -1; 
 
      if (a.created_time > b.created_time) 
 
       return 1; 
 
      return 0; 
 
     } 
 

 
     var html = "<ul>"; 
 
     $.each(messages.sort(compare), function(i, fb) { 
 
      if (typeof fb.picture != "undefined") { 
 
       html += "<li>" + fb.message + "</br>" + '<img SRC="' + fb.picture + '">' + "</br>" + fb.created_time + "</li></br>"; 
 
      } else { 
 
       html += "<li>" + fb.message + "</br>" + fb.created_time + "</li></br>"; 
 
      } 
 
     }); 
 
     html += "</ul>"; 
 
     $('.facebookfeed').html(html); 
 
    }); 
 
} 
 

 
fbFetch();
<div class="facebookfeed"></div>

小提琴這裏:http://jsfiddle.net/6fhq3dat/17/

回答

0

使用full_picture代替picture

var url = "https://graph.facebook.com/?ids=intel&fields=posts.limit(3){message,created_time,full_picture}&access_token=" + access_token; 

demo

+1

感謝快速蝸牛:)作品太棒了! –

相關問題