douewei1665 2013-08-04 20:04
浏览 55
已采纳

Facebook - 在视频应用程序中获取和显示我/ og.likes

Have built an video app that publish user actions towards Facebook.

In this app i have implemented an "Favorite" function that i have hooked up towards a basic open graph action "og.like"

I want to be able to display video's that user liked and apply my own styling to that.

Basically i want to display "Title" "Url" & "Image"

So i use the PHP-SDK towards authored user with active access token and execute

$response = $facebook->api(
'me/og.likes',
'GET'
);
// handle the response

How do i now sort out my correct fields and display them ?

Am not hardcore at either php or javascript but will be able to sort this out if i just can get a little push in the right direction. Like just showing the raw data

Update

Finally a little progress, adding

print_r ($response);

Will write out the raw data, Now i know that am on the right way.

Array returned

{
"data": [
{
  "id": "123", 
  "from": {
    "name": "Mathias", 
    "id": "APP_ID"
  }, 
  "start_time": "X", 
  "end_time": "X", 
  "publish_time": "X", 
  "application": {
    "name": "APP_Name", 
    "namespace": "", 
    "id": "321"
  }, 
  "data": {
    "object": {
      "id": "139", 
      "url": "Url to like", 
      "type": "video.tv_show", 
      "title": "title"
    }
  }, 
  "type": "og.likes", 
  "no_feed_story": false, 
  "likes": {
    "count": 0, 
    "can_like": true, 
    "user_likes": false
  }, 
  "comments": {
    "count": 0, 
    "can_comment": true, 
    "comment_order": "chronological"
  }
}, 

And then the next..

From every app "like" i would like to display Url ,Title & Image

From what i understand so far my main problem is that this is nested arrays, Did try with single level arrays and there i did manage to display correct data just by

 echo $response[name];

So how do i digg in and loop this around, All tips are welcome,

{
 "id": "139", 
 "url": "url", 
 "type": "video.tv_show", 
 "title": "titke", 
 "image": [
   {
     "url":     "image_URL", 
     "secure_url":     "image_URL", 
     "type": "image/jpg", 
     "width": 1024, 
     "height": 576
   }
  • 写回答

1条回答 默认 最新

  • duanjucong3124 2013-08-05 03:13
    关注

    Here's an example:

    <?php foreach ( $response['data'] as $data ): ?>
          <?php $Object = $data['data']['object']; ?>
          <a href="<?php echo $Object['url']; ?>"><?php echo $Object['title']; ?></a><br />
    <?php endforeach; ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料