如何为 Facebook 的新 Graph API 返回的对象构建永久链接? [英] How to construct a permalink for objects returned by Facebook's new Graph API?

查看:11
本文介绍了如何为 Facebook 的新 Graph API 返回的对象构建永久链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Facebook Graph API 允许从 JSON 中获取 Facebook 对象,如帖子、视频等.以下是一个帖子示例:(取自 文档):

Facebook Graph API allows getting Facebook objects like posts, videos etc in JSON from. Here is an example of a post: (taken from the documentation):

{
         "id": "719323658_129694190395214",
         "from": {
            "name": "Rabia Yalcinkaya",
            "id": "719323658"
         },
         "message": "COK MUHTESEM!!!",
         "picture": "http://external.ak.fbcdn.net/safe_image.php?d=41762b7121ee68754ebea48dee4568aa&w=130&h=130&url=http%3A%2F%2Fats.vimeo.com%2F192%2F882%2F19288238_200.jpg",
         "link": "http://vimeo.com/5646785",
         "source": "http://vimeo.com/moogaloop.swf?clip_id=5646785",
         "name": "Watermelon carving",
         "caption": "vimeo.com",
         "description": "Me carving a watermelon.",
         "icon": "http://static.ak.fbcdn.net/rsrc.php/z9XZ8/hash/976ulj6z.gif",
         "type": "video",
         "created_time": "2010-06-23T10:58:17+0000",
         "updated_time": "2010-06-23T10:58:17+0000",
         "likes": 1
      },

如何构建一个 url,让您可以链接回 Facebook 上 Bret 墙上的原始视频(或其他类型)?

How does one construct a url which allows you to link back to the original video (or other types) on Bret's wall on Facebook? something in the form of

http://www.facebook.com/<USER_ID>/video/<VIDEO_ID>

谢谢,波阿斯

推荐答案

actions 字段中有 link 字段(对于每个可用的操作),它恰好包含给定帖子的永久链接.但是,在依赖它之前一定要检查它 - 它可能会改变.我只用过评论"和喜欢".

in the actions field there is the link field (for each available action) which happens to contain the permalink to the given post. However be sure to inspect this before relying on it - it might change. I've only used it with "comment" and "like".

除此之外,您还必须手动构建它.对于设置了用户名的用户(即可以通过 facebook.com/username 访问他们的个人资料,它适用于:

Apart from that you'd have to construct it manually. For users that have their username set (i.e. their profile is accessible via facebook.com/username, it works with:

 http://facebook.com/USERID/posts/POSTID

对于其他一切:

 http://www.facebook.com/permalink.php?id=USERID&v=wall&story_fbid=POSTID

来源:http://forum.developers.facebook.net/viewtopic.php?pid=316384

请注意,POSTID 的格式为 USERID_POSTID,因此您必须删除第一部分.

Note that the POSTID is in the form USERID_POSTID, so you'd have to strip the first part.

这篇关于如何为 Facebook 的新 Graph API 返回的对象构建永久链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆