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 删除虚拟显示器驱动 删除所有 Xorg 配置文件 删除显示器缓存文件 重启系统 可是依旧无法退出虚拟显示器
  • ¥15 vscode程序一直报同样的错,如何解决?
  • ¥15 关于使用unity中遇到的问题
  • ¥15 开放世界如何写线性关卡的用例(类似原神)
  • ¥15 关于并联谐振电磁感应加热
  • ¥60 请查询全国几个煤炭大省近十年的煤炭铁路及公路的货物周转量
  • ¥15 请帮我看看我这道c语言题到底漏了哪种情况吧!
  • ¥66 如何制作支付宝扫码跳转到发红包界面
  • ¥15 pnpm 下载element-plus
  • ¥15 解决编写PyDracula时遇到的问题