[英]Twitter API 1.1 get last 3 statuses
in according to this tutorial: 根据本教程:
$twitteruser = "twitterusername";
$notweets = 3;
$consumerkey = "12345";
$consumersecret = "123456789";
$accesstoken = "123456789";
$accesstokensecret = "12345";
function getConnectionWithAccessToken($cons_key, $cons_secret, $oauth_token, $oauth_token_secret) {
$connection = new TwitterOAuth($cons_key, $cons_secret, $oauth_token, $oauth_token_secret);
return $connection;
}
$connection = getConnectionWithAccessToken($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);
$tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitteruser."&count=".$notweets);
echo json_encode($tweets);
?>
How can I extract from json_encode($tweets);
如何从
json_encode($tweets);
提取json_encode($tweets);
' statuses ' information? ' 状态 '信息?
Why are you using json_encode()
here? 你为什么在这里使用
json_encode()
?
The response from Twitter is a JSON string, and you should use json_decode()
to decode it into an an object/array and print the required values. Twitter的响应是一个JSON字符串,您应该使用
json_decode()
将其解码为一个对象/数组并打印所需的值。
$tweetArray = json_decode($tweets, TRUE); // or json_decode($tweets); for an object
foreach($tweetArray as $value) {
// do the printing ...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.