如何为 Facebook 的新 Graph API 返回的对象构建永久链接?

发布于 2024-09-07 02:31:18 字数 1222 浏览 1 评论 0原文

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

{
         "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
      },

How does one Construction a url它允许您链接回 Facebook 上 Bret 墙上的原始视频(或其他类型)?以感谢的形式表达的东西

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

, 波阿斯

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
      },

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>

Thanks,
Boaz

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别把无礼当个性 2024-09-14 02:31:18

actions 字段中,有一个 link 字段(针对每个可用操作),该字段恰好包含给定帖子的永久链接。然而,在依赖它之前一定要检查它——它可能会改变。我只将它与“评论”和“喜欢”一起使用。

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

 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,因此您必须删除第一部分。

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".

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

For everything else:

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

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文