从Twitter API中获取用户时间线的仅选定字段

3

我正在从一个iOS应用程序获取用户的时间线,从API中检索了大量推文。我正在使用 statuses/user_timeline 端点获取数据,但由于我在移动设备上,并且我只需要推文文本,因此我想仅过滤推文的实际文本数据。我已经将 include_entities 设置为 no,并将 trim_user 设置为 true,但即使修剪了实体和用户数据,我仍然得到了很多不需要的数据。这是我从端点获取的一个示例推文:

{
"created_at": "Tue Nov 27 14:13:13 +0000 2012",
"id": 273429272209801200,
"id_str": "273429272209801217",
"text": "you could list #5ThingsIFindAttractive but you can actually find them on Facebook with Social Match on iPhone! http://t.co/zRr1ggbz",
"source": "web",
"truncated": false,
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"in_reply_to_screen_name": null,
"user": {
  "id": 62828168,
  "id_str": "62828168"
},
"geo": null,
"coordinates": null,
"place": {
  "id": "682c5a667856ef42",
  "url": "http://api.twitter.com/1/geo/id/682c5a667856ef42.json",
  "place_type": "country",
  "name": "Turkey",
  "full_name": "Turkey",
  "country_code": "TR",
  "country": "Turkey",
  "bounding_box": {
    "type": "Polygon",
    "coordinates": [
      [
        [
          25.663883,
          35.817497
        ],
        [
          44.822762,
          35.817497
        ],
        [
          44.822762,
          42.109993
        ],
        [
          25.663883,
          42.109993
        ]
      ]
    ]
  },
  "attributes": {}
},
"contributors": null,
"retweet_count": 0,
"favorited": false,
"retweeted": false,
"possibly_sensitive": false

我实际上只需要字典中的text键,其余部分对我的应用程序来说目前是无用的。我将请求许多这样的推文。如何发送一个请求只获取推文中的text键?目前,这种方法非常低效。

1个回答

1

你不能这样做。最好的方法是设置一个代理,请求数据,剥离它,然后将其转发到移动设备。

如果有什么安慰的话,JSON 将被压缩,并且应该仍然相对较小 - 因此不会花费太长时间来传输或消耗用户的数据配额。


好的,我将使用gzip压缩数据,这对我的情况最好。很遗憾看到没有类似于Facebook图形/ FQL API的等效物,我们可以选择我们只需要的字段。 - Can Poyrazoğlu

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接