我正在使用Twitter API检索推文,我这样做:
我检查他们是否有quoted_status,然后我替换url_info->url
中tweet_data->quoted_status->id_str
内url_info->expanded_url
的网址。这样,我知道URL是引用的推文之一,我可以恢复数据并在下面显示。
这通常有效,但不是这条推文:
stdClass Object
(
[created_at] => Wed Dec 14 08:30:32 +0000 2016
[id] => 8.0895229853789E+17
[id_str] => 808952298537885696
[text] => Volem felicitar al Centre d'Estudis Montseny, guanyadors d'aquest concurs, i a @stlisieux, que han estat finalistes… 'shortened_url'/CGqkTNPPB1
[truncated] => 1
[entities] => stdClass Object
(
[hashtags] => Array
(
)
[symbols] => Array
(
)
[user_mentions] => Array
(
[0] => stdClass Object
(
[screen_name] => stlisieux
[name] => Col·legi ST Lisieux
[id] => 3064329677
[id_str] => 3064329677
[indices] => Array
(
[0] => 79
[1] => 89
)
)
)
[urls] => Array
(
[0] => stdClass Object
(
[url] => 'shortened_url'CGqkTNPPB1
[expanded_url] => https://twitter.com/i/web/status/808952298537885696
[display_url] => twitter.com/i/web/status/8…
[indices] => Array
(
[0] => 117
[1] => 140
)
)
)
)
[source] => Twitter Web Client
[in_reply_to_status_id] =>
[in_reply_to_status_id_str] =>
[in_reply_to_user_id] =>
[in_reply_to_user_id_str] =>
[in_reply_to_screen_name] =>
[user] => stdClass Object
(
[id] => 493037120
[id_str] => 493037120
[name] => Clickedu
[screen_name] => Clickedu
[location] => España
[description] => La plataforma para colegios e institutos. | La plataforma per a escoles i instituts. 'shortened_url'/NBZbqw7Qpn
[url] => 'shortened_url'/00a8v8WUv5
[entities] => stdClass Object
(
[url] => stdClass Object
(
[urls] => Array
(
[0] => stdClass Object
(
[url] => 'shortened_url'/00a8v8WUv5
[expanded_url] => http://www.clickartedu.com/
[display_url] => clickartedu.com
[indices] => Array
(
[0] => 0
[1] => 22
)
)
)
)
[description] => stdClass Object
(
[urls] => Array
(
[0] => stdClass Object
(
[url] => 'shortened_url'/NBZbqw7Qpn
[expanded_url] => http://www.clickedu.eu
[display_url] => clickedu.eu
[indices] => Array
(
[0] => 85
[1] => 107
)
)
)
)
)
[protected] =>
[followers_count] => 2960
[friends_count] => 1998
[listed_count] => 79
[created_at] => Wed Feb 15 11:29:55 +0000 2012
[favourites_count] => 8529
[utc_offset] => 3600
[time_zone] => Madrid
[geo_enabled] => 1
[verified] =>
[statuses_count] => 3840
[lang] => ca
[contributors_enabled] =>
[is_translator] =>
[is_translation_enabled] =>
[profile_background_color] => AD0C40
[profile_background_image_url] => http://pbs.twimg.com/profile_background_images/444501732022697984/vMM1qgYt.jpeg
[profile_background_image_url_https] => https://pbs.twimg.com/profile_background_images/444501732022697984/vMM1qgYt.jpeg
[profile_background_tile] =>
[profile_image_url] => http://pbs.twimg.com/profile_images/567973366670172160/1opAPyhE_normal.jpeg
[profile_image_url_https] => https://pbs.twimg.com/profile_images/567973366670172160/1opAPyhE_normal.jpeg
[profile_banner_url] => https://pbs.twimg.com/profile_banners/493037120/1477042035
[profile_link_color] => AD0C40
[profile_sidebar_border_color] => FFFFFF
[profile_sidebar_fill_color] => DDEEF6
[profile_text_color] => 333333
[profile_use_background_image] => 1
[has_extended_profile] =>
[default_profile] =>
[default_profile_image] =>
[following] =>
[follow_request_sent] =>
[notifications] =>
[translator_type] => none
)
[geo] =>
[coordinates] =>
[place] =>
[contributors] =>
[is_quote_status] => 1
[quoted_status_id] => 8.0870805032451E+17
[quoted_status_id_str] => 808708050324508672
[quoted_status] => stdClass Object
(
[created_at] => Tue Dec 13 16:19:58 +0000 2016
[id] => 8.0870805032451E+17
[id_str] => 808708050324508672
[text] => Aixà és com veuen l’ictus els alumnes del Centre d’Estudis Montseny, que han guanyat el 18è concurs Pinta La Marató… 'shortened_url'/tts4uGmKWy
[truncated] => 1
[entities] => stdClass Object
(
[hashtags] => Array
(
)
[symbols] => Array
(
)
[user_mentions] => Array
(
)
[urls] => Array
(
[0] => stdClass Object
(
[url] => 'shortened_url'/tts4uGmKWy
[expanded_url] => https://twitter.com/i/web/status/808708050324508672
[display_url] => twitter.com/i/web/status/8…
[indices] => Array
(
[0] => 117
[1] => 140
)
)
)
)
[source] => Twitter Web Client
[in_reply_to_status_id] =>
[in_reply_to_status_id_str] =>
[in_reply_to_user_id] =>
[in_reply_to_user_id_str] =>
[in_reply_to_screen_name] =>
[user] => stdClass Object
(
[id] => 18045654
[id_str] => 18045654
[name] => La Marató
[screen_name] => la_marato
[location] => Catalunya
[description] => El 18 de desembre La Marató fa 25 anys amb un programa dedicat a l'ictus i les lesions medul·lars i cerebrals traumà tiques.
[url] => 'shortened_url'/iCXlb20x3w
[entities] => stdClass Object
(
[url] => stdClass Object
(
[urls] => Array
(
[0] => stdClass Object
(
[url] => 'shortened_url'/iCXlb20x3w
[expanded_url] => http://www.tv3.cat/marato/
[display_url] => tv3.cat/marato/
[indices] => Array
(
[0] => 0
[1] => 22
)
)
)
)
[description] => stdClass Object
(
[urls] => Array
(
)
)
)
[protected] =>
[followers_count] => 46627
[friends_count] => 352
[listed_count] => 333
[created_at] => Thu Dec 11 11:38:21 +0000 2008
[favourites_count] => 1469
[utc_offset] => 3600
[time_zone] => Madrid
[geo_enabled] =>
[verified] =>
[statuses_count] => 3160
[lang] => ca
[contributors_enabled] =>
[is_translator] =>
[is_translation_enabled] =>
[profile_background_color] => DCE4E8
[profile_background_image_url] => http://pbs.twimg.com/profile_background_images/378800000099697740/e6dc40b2a9233a582dc14394aed732a7.jpeg
[profile_background_image_url_https] => https://pbs.twimg.com/profile_background_images/378800000099697740/e6dc40b2a9233a582dc14394aed732a7.jpeg
[profile_background_tile] =>
[profile_image_url] => http://pbs.twimg.com/profile_images/748843776345513985/WXSEA15G_normal.jpg
[profile_image_url_https] => https://pbs.twimg.com/profile_images/748843776345513985/WXSEA15G_normal.jpg
[profile_banner_url] => https://pbs.twimg.com/profile_banners/18045654/1481702408
[profile_link_color] => 0084B4
[profile_sidebar_border_color] => FFFFFF
[profile_sidebar_fill_color] => DDEEF6
[profile_text_color] => 333333
[profile_use_background_image] => 1
[has_extended_profile] =>
[default_profile] =>
[default_profile_image] =>
[following] =>
[follow_request_sent] =>
[notifications] =>
[translator_type] => none
)
[geo] =>
[coordinates] =>
[place] =>
[contributors] =>
[is_quote_status] =>
[retweet_count] => 15
[favorite_count] => 21
[favorited] =>
[retweeted] =>
[possibly_sensitive] =>
[lang] => und
)
[retweet_count] => 2
[favorite_count] => 2
[favorited] =>
[retweeted] =>
[possibly_sensitive] =>
[lang] => und
)
在这里,[expanded_url] => https://twitter.com/i/web/status/808952298537885696
指向推文本身,而不是像往常一样指向引用的推文。
答案 0 :(得分:1)
由于此推文中的truncated
值为true
(1),因此表示您正在查看扩展的推文。您可以在Twitter开发人员Upcoming Changes to Tweets文档中阅读有关新Tweet格式的更多信息。如果您使用tweet_mode=extended
选项,您将能够检索完整的推文,而无需嵌入链接到推文的网络版本。