android - Android 中的图形 API

标签 android facebook facebook-graph-api

我对使用 Facebook 图形 API 感到非常困惑。例如。如果我这样做: https://graph.facebook.com/me/feed ,我得到:

{
  "data": [
    {
      "id": "123456",
      "from": {
        "name": "Souvik Basu",
        "id": "123456"
      },
      "story": "Souvik Basu shared \"jus'sayin\"'s photo.",
      "story_tags": {
        "19": [
          {
            "id": "123456",
            "name": "\"jus'sayin\"",
            "offset": 19,
            "length": 11,
            "type": "page"
          }
        ],
        "0": [
          {
            "id": 123456,
            "name": "Souvik Basu",
            "offset": 0,
            "length": 11,
            "type": "user"
          }
        ]

但是,我如何在我的 android 代码中获取特定的故事?还有为什么会有第 19 个和第 0 个 sory 标签? 我有标准的 Facebook-Android 代码。

最佳答案

我不明白你的问题到底在哪里...

您使用的是 facebook android sdk ?如果是这样,那么将图形对象获取到您的“android 代码”就非常简单,例如:

Facebook facebook = new Facebook(...);

String response = facebook.request("/me/feed");
JSONObject json = Util.parseJson(response);
JSONArray data = json.getJSONArray("data");

此示例显示正常 API Requests但你也可以使用 Async API Requests .

至于 story_tags 的键,这就是它在 documentation 中所说的:

object containing fields whose names are the indexes to where objects are mentioned in the message field; each field in turn is an array containing an object with id, name, offset, and length fields, where length is the length, within the message field, of the object mentioned

关于android - Android 中的图形 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9652729/

相关文章:

Facebook API : "Share" a post already posted on a page's wall?

facebook-graph-api - 用于搜索任何内容的 facebook graph api 文档在哪里

java - 如何正确使用带套接字的 HandlerThread?

android - 如何在没有任何签名的情况下使用已处理的应用程序运行 Wear 应用程序?我的意思是开发者 Debug模式

跨不同平台的 facebook 用户访问 token

ios - DiskCookieStorage 改变策略从 2 到 0 - 受众网络 NativeAdSample

facebook-graph-api - 如何为 URL 获取适当的 Facebook 点赞数

android - 如何将数据从 Activity 发送到 Fragment

android - AdvancedWebView 从手机存储问题加载 html

ios - 在所有请求完成后执行代码(Facebook SDK)