dsideal2015 2014-01-27 00:01
浏览 45
已采纳

使用Graph JSON获取Facebook公共页面相册,并使用ACCESS KEY通过PHP生成HTML输出

So I'm trying to grab the graph feed of a (public) Fb page album in PHP, convert the JSON feed to html and output. I found this URL that seems to get me part way:

https://graph.facebook.com/fql?q=select%20src,created,caption%20from%20photo%20where%20album_object_id=391495207538675%20order%20by%20created%20desc%20limit%20100

I appreciate that there's a limit of 100 images, which is fine. What I'm struggling with is the access key. I understand that this is needed (although I can get the JSON of any public page album without it - not sure how that works). So:

  1. Why do I need it (access token)? I assume so that my page/feed doesn't get blacklisted by FB?
  2. How do I use the access token? I added "manage_pages" from "Get access token/Extended permissions". This gives me my Access token relating to my personal profile, right? I tried adding it in the URL above (i.e. ... where album_object_id=391495207538675 AND access_token=ABCDE) but I got: "(#602) access_token is not a member of the photo table."
  3. How can I then best process this into some img's on page?

I've read a good number of items in S.O. about this but some seem out of date now when I follow the steps, others lost me part way through, some are a little advanced for my newbie skills, but help would be appreciated. Apologies if I sound like I'm getting confused here, but ... I am.

  • 写回答

2条回答 默认 最新

  • duanchan9354 2016-04-08 17:42
    关注

    You can use this method below.

    id=FACEBOOK USER ID & PHOTO ALBUL ID

    $query = "SELECT aid,object_id,name,size,type FROM album WHERE owner = '$id' ORDER BY modified DESC";}
                $url = 'https://graph.facebook.com/fql?q='.rawurlencode($query).'&format=json-strings';
    
                $ch = curl_init($url);
                curl_setopt($ch, CURLOPT_HEADER,0);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
                $return_data = curl_exec($ch);
                $json_array = json_decode($return_data,true);
    
                return $json_array;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 对于知识的学以致用的解释
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败