duanlang0025 2015-09-03 05:30
浏览 48

使用graph api在个人网络应用程序中获取Facebook提要

I am trying to display all the posts that are added in a Facebook page.I have used a Facebook SDk and graph api http GET request to fetch the posts.I have been successful in fetching such posts.

I just want how can i display those posts in following order:

Post1 image Post 2 Image

Post 1 description Post 2 Description

Here is the code i have done till now: This is JS file :

(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.2";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

$( document ).ready(function() {
    fbFetch();
});
function fbFetch(){
    var url = "https://graph.facebook.com/{MyPageID}/posts?fields=picture,description,message&access_token={MyPageAscesToken}";
$.getJSON( url, function( data ) {

  $.each( data, function( key, val ) {

      $.each( val, function( keys, value ) {

              $( ".picture_name" ).append( value["message"]); 

              $( "<img>" ).attr( "src", value["picture"]).appendTo( ".facebookfeed" ); 

     });

   });
});
};

This Is my view page COde:

<div class="row-inlineblock">
                        <div class="col-sm-12 col-xs-5">
                        <figure class="facebookfeed"></figure>
                        </div>
                        <div class="col-sm-12 col-xs-7">

                            <h2 class="picture_name"></h2>
                        </div>
                    </div>
  • 写回答

1条回答 默认 最新

  • duangou1551 2015-09-17 13:17
    关注

    i was able to solve the problem Just needed to use <ul>,<li> kind of stuff in view page and also changing the iteration of JSON to reduce the .$each to make it javscript code more fast.

    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP