使用https://api.twitter.com/1.1/statuses/mentions_timeline.json
时,我很难理解API调用的结构。
根据他们的documentation in_reply_to_status_id_str
被称为
如果代表的Tweet是回复,则此字段将包含原始Tweet ID的字符串表示形式
我了解的那部分是,因此您可以知道与原始推文相关的回复是什么。有道理...
现在在原始推文中它将在id_str
问题是,即使我有推文并进行回复,查看数组时,in_reply_to_status_id_str
的ID仍与之关联,但该ID却与原始的推文ID不匹配。
这是我收到的示例输出。如果数组很大,请原谅。
Array
(
[0] => stdClass Object
(
[created_at] => Wed Jul 25 23:25:31 +0000 2018
[id] => 1022261593520857088
[id_str] => 1022261593520857088
[text] => @somecompany test https://example.com/0D83Rp32ZA
[truncated] =>
[extended_entities] => stdClass Object
(
[media] => Array
(
[0] => stdClass Object
(
[id] => 1022261588324016128
[id_str] => 1022261588324016128
[indices] => Array
(
[0] => 19
[1] => 42
)
[media_url] => http://pbs.twimg.com/media/Di_Nf5eUYAA58XD.jpg
[media_url_https] => https://pbs.twimg.com/media/Di_Nf5eUYAA58XD.jpg
[url] => https://example.com/0D83Rp32ZA
[display_url] => pic.twitter.com/0D83Rp32ZA
[expanded_url] => https://twitter.com/jsmith/status/1022261593520857088/photo/1
[type] => photo
[sizes] => stdClass Object
(
[thumb] => stdClass Object
(
[w] => 150
[h] => 150
[resize] => crop
)
[small] => stdClass Object
(
[w] => 640
[h] => 480
[resize] => fit
)
[large] => stdClass Object
(
[w] => 640
[h] => 480
[resize] => fit
)
[medium] => stdClass Object
(
[w] => 640
[h] => 480
[resize] => fit
)
)
)
)
)
[source] => <a href="http://twitter.com" rel="nofollow">Twitter Web Client</a>
[in_reply_to_status_id] =>
[in_reply_to_status_id_str] =>
[in_reply_to_user_id] => 874407123177713664
[in_reply_to_user_id_str] => 874407123177713664
[in_reply_to_screen_name] => somecompany
[user] => stdClass Object
(
[id] => 55914522
[id_str] => 55914522
[name] => John Smith
[screen_name] => jsmith
[location] => Las Vegas, NV
[description] => Coder, Sys Admin, Star Wars Lover and #SEO FTW
[url] => https://example.com/X76OkU3gFw
[entities] => stdClass Object
(
[url] => stdClass Object
(
[urls] => Array
(
[0] => stdClass Object
(
[url] => https://example.com/X76OkU3gFw
[expanded_url] => http://www.somecompany.com
[display_url] => somecompany.com
[indices] => Array
(
[0] => 0
[1] => 23
)
)
)
)
[description] => stdClass Object
(
[urls] => Array
(
)
)
)
[protected] =>
[followers_count] => 172
[friends_count] => 59
[listed_count] => 2
[created_at] => Sat Jul 11 19:55:42 +0000 2009
[favourites_count] => 59
[utc_offset] =>
[time_zone] =>
[geo_enabled] => 1
[verified] =>
[statuses_count] => 675
[lang] => en
[contributors_enabled] =>
[is_translator] =>
[is_translation_enabled] =>
[profile_background_color] => 131516
[profile_background_image_url] => http://abs.twimg.com/images/themes/theme14/bg.gif
[profile_background_image_url_https] => https://abs.twimg.com/images/themes/theme14/bg.gif
[profile_background_tile] => 1
[profile_image_url] => http://pbs.twimg.com/profile_images/423584132547891200/HxV6vRel_normal.jpeg
[profile_image_url_https] => https://pbs.twimg.com/profile_images/423584132547891200/HxV6vRel_normal.jpeg
[profile_banner_url] => https://pbs.twimg.com/profile_banners/55914522/1497644070
[profile_link_color] => 009999
[profile_sidebar_border_color] => EEEEEE
[profile_sidebar_fill_color] => EFEFEF
[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] => 0
[favorite_count] => 1
[favorited] =>
[retweeted] =>
[possibly_sensitive] =>
[lang] => en
)
[1] => stdClass Object
(
[created_at] => Wed Jul 25 23:50:13 +0000 2018
[id] => 1022267810850852864
[id_str] => 1022267810850852864
[text] => @somecompany Back To you
[truncated] =>
[source] => <a href="http://twitter.com" rel="nofollow">Twitter Web Client</a>
[in_reply_to_status_id] => 1022266741638934529
[in_reply_to_status_id_str] => 1022266741638934529
[in_reply_to_user_id] => 874407123177713664
[in_reply_to_user_id_str] => 874407123177713664
[in_reply_to_screen_name] => somecompany
[user] => stdClass Object
(
[id] => 55914522
[id_str] => 55914522
[name] => John Smith
[screen_name] => jsmith
[location] => Las Vegas, NV
[description] => Coder, Sys Admin, Star Wars Lover and #SEO FTW
[url] => https://example.com/X76OkU3gFw
[entities] => stdClass Object
(
[url] => stdClass Object
(
[urls] => Array
(
[0] => stdClass Object
(
[url] => https://example.com/X76OkU3gFw
[expanded_url] => http://www.somecompany.com
[display_url] => somecompany.com
[indices] => Array
(
[0] => 0
[1] => 23
)
)
)
)
[description] => stdClass Object
(
[urls] => Array
(
)
)
)
[protected] =>
[followers_count] => 172
[friends_count] => 59
[listed_count] => 2
[created_at] => Sat Jul 11 19:55:42 +0000 2009
[favourites_count] => 59
[utc_offset] =>
[time_zone] =>
[geo_enabled] => 1
[verified] =>
[statuses_count] => 675
[lang] => en
[contributors_enabled] =>
[is_translator] =>
[is_translation_enabled] =>
[profile_background_color] => 131516
[profile_background_image_url] => http://abs.twimg.com/images/themes/theme14/bg.gif
[profile_background_image_url_https] => https://abs.twimg.com/images/themes/theme14/bg.gif
[profile_background_tile] => 1
[profile_image_url] => http://pbs.twimg.com/profile_images/423584132547891200/HxV6vRel_normal.jpeg
[profile_image_url_https] => https://pbs.twimg.com/profile_images/423584132547891200/HxV6vRel_normal.jpeg
[profile_banner_url] => https://pbs.twimg.com/profile_banners/55914522/1497644070
[profile_link_color] => 009999
[profile_sidebar_border_color] => EEEEEE
[profile_sidebar_fill_color] => EFEFEF
[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] => 0
[favorite_count] => 0
[favorited] =>
[retweeted] =>
[lang] => en
)
[2] => stdClass Object
(
[created_at] => Thu Jul 26 18:13:20 +0000 2018
[id] => 1022545418192740352
[id_str] => 1022545418192740352
[text] => @somecompany @jsmith I like
[truncated] =>
[source] => <a href="http://twitter.com/download/iphone" rel="nofollow">Twitter for iPhone</a>
[in_reply_to_status_id] => 1022266300872048641
[in_reply_to_status_id_str] => 1022266300872048641
[in_reply_to_user_id] => 874407123177713664
[in_reply_to_user_id_str] => 874407123177713664
[in_reply_to_screen_name] => somecompany
[user] => stdClass Object
(
[id] => 508050392
[id_str] => 508050392
[name] => Josh
[screen_name] => jcarp53
[location] => nunya, bidness
[description] =>
[url] =>
[entities] => stdClass Object
(
[description] => stdClass Object
(
[urls] => Array
(
)
)
)
[protected] =>
[followers_count] => 48
[friends_count] => 183
[listed_count] => 0
[created_at] => Tue Feb 28 23:03:17 +0000 2012
[favourites_count] => 359
[utc_offset] =>
[time_zone] =>
[geo_enabled] =>
[verified] =>
[statuses_count] => 798
[lang] => en
[contributors_enabled] =>
[is_translator] =>
[is_translation_enabled] =>
[profile_background_color] => C0DEED
[profile_background_image_url] => http://abs.twimg.com/images/themes/theme1/bg.png
[profile_background_image_url_https] => https://abs.twimg.com/images/themes/theme1/bg.png
[profile_background_tile] =>
[profile_image_url] => http://pbs.twimg.com/profile_images/3598324323/914b87cec022095e4bbde9cc4ee902fc_normal.jpeg
[profile_image_url_https] => https://pbs.twimg.com/profile_images/3598324323/914b87cec022095e4bbde9cc4ee902fc_normal.jpeg
[profile_banner_url] => https://pbs.twimg.com/profile_banners/508050392/1367383299
[profile_link_color] => 1DA1F2
[profile_sidebar_border_color] => C0DEED
[profile_sidebar_fill_color] => DDEEF6
[profile_text_color] => 333333
[profile_use_background_image] => 1
[has_extended_profile] =>
[default_profile] => 1
[default_profile_image] =>
[following] =>
[follow_request_sent] =>
[notifications] =>
[translator_type] => none
)
[geo] =>
[coordinates] =>
[place] =>
[contributors] =>
[is_quote_status] =>
[retweet_count] => 0
[favorite_count] => 0
[favorited] =>
[retweeted] =>
[lang] => en
)
[3] => stdClass Object
(
[created_at] => Thu Jul 26 19:39:06 +0000 2018
[id] => 1022567004270551040
[id_str] => 1022567004270551040
[text] => @somecompany Another test
[truncated] =>
[source] => <a href="http://twitter.com" rel="nofollow">Twitter Web Client</a>
[in_reply_to_status_id] =>
[in_reply_to_status_id_str] =>
[in_reply_to_user_id] => 874407123177713664
[in_reply_to_user_id_str] => 874407123177713664
[in_reply_to_screen_name] => somecompany
[user] => stdClass Object
(
[id] => 55914522
[id_str] => 55914522
[name] => John Smith
[screen_name] => jsmith
[location] => Las Vegas, NV
[description] => Coder, Sys Admin, Star Wars Lover and #SEO FTW
[url] => https://example.com/X76OkU3gFw
[entities] => stdClass Object
(
[url] => stdClass Object
(
[urls] => Array
(
[0] => stdClass Object
(
[url] => https://example.com/X76OkU3gFw
[expanded_url] => http://www.somecompany.com
[display_url] => somecompany.com
[indices] => Array
(
[0] => 0
[1] => 23
)
)
)
)
[description] => stdClass Object
(
[urls] => Array
(
)
)
)
[protected] =>
[followers_count] => 172
[friends_count] => 59
[listed_count] => 2
[created_at] => Sat Jul 11 19:55:42 +0000 2009
[favourites_count] => 59
[utc_offset] =>
[time_zone] =>
[geo_enabled] => 1
[verified] =>
[statuses_count] => 675
[lang] => en
[contributors_enabled] =>
[is_translator] =>
[is_translation_enabled] =>
[profile_background_color] => 131516
[profile_background_image_url] => http://abs.twimg.com/images/themes/theme14/bg.gif
[profile_background_image_url_https] => https://abs.twimg.com/images/themes/theme14/bg.gif
[profile_background_tile] => 1
[profile_image_url] => http://pbs.twimg.com/profile_images/423584132547891200/HxV6vRel_normal.jpeg
[profile_image_url_https] => https://pbs.twimg.com/profile_images/423584132547891200/HxV6vRel_normal.jpeg
[profile_banner_url] => https://pbs.twimg.com/profile_banners/55914522/1497644070
[profile_link_color] => 009999
[profile_sidebar_border_color] => EEEEEE
[profile_sidebar_fill_color] => EFEFEF
[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] => 0
[favorite_count] => 0
[favorited] =>
[retweeted] =>
[lang] => en
)
)
此数组中有2个提及。第一个原始推文的id_str
为1022261593520857088。根据文档,对原始推文的以下答复应在in_reply_to_status_id_str
中包含该ID。如果您发现原始ID在其他in_reply_to_status_id_str
中没有任何位置,包括对该推文的答复。因此,我对文档说明感到困惑,在文档说明中它指定应包含原始tweet的ID ...不是。
我想做的是能够导入推文并回复并关联它们,但是直到我能找到原始推文和相关回复之间的公共链接,我才能做任何事情。