可能的重复:
判断一条推文是否是转推?
因此,我一直在研究一个 twitter 提要脚本,该脚本可以引入我的提要。我想知道如何检查特定推文是否被转推,然后如果它被转推,我想使用转推推文中的信息。这是 twitter API 为转推生成的示例关联数组。
Array
(
[0] => Array
(
[created_at] => Sun Jan 06 08:28:39 +0000 2013
[id] => 287838076443705345
[id_str] => 287838076443705345
[text] => RT @Fullscreen: Heads-up: many YT partners are reporting issues claiming their videos. It appears to be a YT bug. We will keep you posted.
[source] => web
...
[user] => Array
(
[id] => 212642904
[id_str] => 212642904
[name] => Elias Ranz-Schleifer
[screen_name] => Xxplosions
...
)
...
[retweeted_status] => Array
(
[created_at] => Sun Jan 06 02:08:43 +0000 2013
[id] => 287742460824805378
[id_str] => 287742460824805378
[text] => Heads-up: many YT partners are reporting issues claiming their videos. It appears to be a YT bug. We will keep you posted.
...
[user] => Array
(
[id] => 238110322
[id_str] => 238110322
[name] => Fullscreen, Inc.
[screen_name] => Fullscreen
...
)
...
)
[retweet_count] => 44
...
)
)
所以基本上我只想在它存在的情况下[text] => RT @Fullscreen: Heads-up: many...
替换它。[text] => Heads-up: many...
如果它不存在,则使用从推文中提取信息的正常方法。我想基本上我想要了解的是如何检查是否[retweeted_status]
存在然后提取该信息,如果不存在则提取其他信息。我想避免将 RT 放在那里,因为它似乎是可能的,并使用类似的信息id_str, text, screen_name, etc.
我用来获取常规推文拉取信息的代码是:
id = tweets[i]["id_str"];
twitPic = tweets[0]["user"]["profile_image_url_https"];
content = tweets[i]["text"];
tweetTime = tweets[i]["created_at"];
wherei
被 for 循环中的索引替换。如果您对我想要了解的内容有任何疑问,请告诉我,我很乐意为您解答。