我正在使用 php 来查找状态已获得的转推数。
这是我当前的代码:
//get account info
$connection->request('GET',$connection->url('1.1/statuses/retweets'),
array('id'=> '363332903113351168'));
//get http response code for request
$response_code = $connection->response['code'];
//convert the json response to an array
$response_data = json_decode($connection->response['response'],true);
if($code != 200)
{
print"ERROR: $response_code\n";
}
print_r($response_data);
如您所见,这会返回一堆关于转推的属性。我正在尝试获取 retweet_count 值。我该怎么做呢?
编辑:这是返回值的数组:
Array
(
[0] => Array
(
[created_at] => Fri Aug 02 20:34:25 +0000 2013
[id] => 3.63397397311E+17
[id_str] => 363397397311135746
[text] => RT @TAN_DUM: Hello Twitter
[source] => Twitter for iPhone
[truncated] =>
[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] => Array
(
[id] => 1613117785
[id_str] => 1613117785
[name] => //Name
[screen_name] => //username
[location] =>
[description] =>
[url] =>
[entities] => Array
(
[description] => Array
(
[urls] => Array
(
)
)
)
[protected] =>
[followers_count] => 2
[friends_count] => 5
[listed_count] => 0
[created_at] => Mon Jul 22 15:42:46 +0000 2013
[favourites_count] => 0
[utc_offset] => -10800
[time_zone] => Atlantic Time (Canada)
[geo_enabled] =>
[verified] =>
[statuses_count] => 1
[lang] => en
[contributors_enabled] =>
[is_translator] =>
[profile_background_color] => C0DEED
[profile_background_image_url] => http://a0.twimg.com/images/themes/theme1/bg.png
[profile_background_image_url_https] => https://si0.twimg.com/images/themes/theme1/bg.png
[profile_background_tile] =>
[profile_image_url] => http://a0.twimg.com/sticky/default_profile_images/default_profile_6_normal.png
[profile_image_url_https] => https://si0.twimg.com/sticky/default_profile_images/default_profile_6_normal.png
[profile_link_color] => 0084B4
[profile_sidebar_border_color] => C0DEED
[profile_sidebar_fill_color] => DDEEF6
[profile_text_color] => 333333
[profile_use_background_image] => 1
[default_profile] => 1
[default_profile_image] => 1
[following] =>
[follow_request_sent] =>
[notifications] =>
)
[geo] =>
[coordinates] =>
[place] =>
[contributors] =>
[retweeted_status] => Array
(
[created_at] => Fri Aug 02 16:18:09 +0000 2013
[id] => 3.63332903113E+17
[id_str] => 363332903113351168
[text] => Hello Twitter
[source] => Tandum
[truncated] =>
[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] => Array
(
[id] => 1638167988
[id_str] => 1638167988
[name] => Tandum
[screen_name] => TAN_DUM
[location] =>
[description] =>
[url] =>
[entities] => Array
(
[description] => Array
(
[urls] => Array
(
)
)
)
[protected] =>
[followers_count] => 0
[friends_count] => 0
[listed_count] => 0
[created_at] => Thu Aug 01 15:14:27 +0000 2013
[favourites_count] => 0
[utc_offset] => -10800
[time_zone] => Atlantic Time (Canada)
[geo_enabled] =>
[verified] =>
[statuses_count] => 2
[lang] => en
[contributors_enabled] =>
[is_translator] =>
[profile_background_color] => C0DEED
[profile_background_image_url] => http://a0.twimg.com/images/themes/theme1/bg.png
[profile_background_image_url_https] => https://si0.twimg.com/images/themes/theme1/bg.png
[profile_background_tile] =>
[profile_image_url] => http://a0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png
[profile_image_url_https] => https://si0.twimg.com/sticky/default_profile_images/default_profile_2_normal.png
[profile_link_color] => 0084B4
[profile_sidebar_border_color] => C0DEED
[profile_sidebar_fill_color] => DDEEF6
[profile_text_color] => 333333
[profile_use_background_image] => 1
[default_profile] => 1
[default_profile_image] => 1
[following] =>
[follow_request_sent] =>
[notifications] =>
)
[geo] =>
[coordinates] =>
[place] =>
[contributors] =>
[retweet_count] => 1
[favorite_count] => 0
[entities] => Array
(
[hashtags] => Array
(
)
[symbols] => Array
(
)
[urls] => Array
(
)
[user_mentions] => Array
(
)
)
[favorited] =>
[retweeted] =>
[lang] => no
)
[retweet_count] => 1
[favorite_count] => 0
[entities] => Array
(
[hashtags] => Array
(
)
[symbols] => Array
(
)
[urls] => Array
(
)
[user_mentions] => Array
(
[0] => Array
(
[screen_name] => TAN_DUM
[name] => Tandum
[id] => 1638167988
[id_str] => 1638167988
[indices] => Array
(
[0] => 3
[1] => 11
)
)
)
)
[favorited] =>
[retweeted] =>
[lang] => no
)
)