由于截至2013年6月11日的Twitter API 1.0退出,下面的脚本不再起作用.
// Create curl resource
$ch = curl_init();
// Set url
curl_setopt($ch, CURLOPT_URL, "http://twitter.com/statuses/user_timeline/myscreenname.json?count=10");
// Return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);
// Close curl resource to free up system resources
curl_close($ch);
if ($output)
{
$tweets = json_decode($output,true);
foreach ($tweets as $tweet)
{
print_r($tweet);
}
}
Run Code Online (Sandbox Code Playgroud)
如何以尽可能少的代码获取user_timeline(最近的状态)?
我发现了这个:https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline 但我收到以下错误:
"{"errors":[{"message":"Could not authenticate you","code":32}]}"
Run Code Online (Sandbox Code Playgroud)
有很多课程,但在尝试了几个之后,由于Twitter上的这些更新,它们中的任何一个似乎都不起作用,而且其中一些是非常高级的类,具有很多我不需要的功能.
使用PHP获取最近用户状态的最简单/最短方法是什么?
array_key_exists不适用于大型多维数组.对于前者
$arr = array(
'1' => 10,
'2' => array(
'21' => 21,
'22' => 22,
'23' => array(
'test' => 100,
'231' => 231
),
),
'3' => 30,
'4' => 40
);
Run Code Online (Sandbox Code Playgroud)
array_key_exists('test',$ arr)返回'false'但它适用于一些简单的数组.