1

我正在尝试在网页上显示最新的推文,但我不确定该怎么做,因为我对 twitter api 非常陌生,但这是我迄今为止所拥有的。

function my_streaming_callback($data, $length, $metrics) {
  echo $data;
}

require '../tmhOAuth.php';
$tmhOAuth = new tmhOAuth(array(
  'consumer_key'    => 'key',
  'consumer_secret' => 'secret',
  'user_token'      => 'token',
  'user_secret'     => 'secret',
));

$method = 'http://stream.twitter.com/1/statuses//show/:id.json';
//not sure where I am supposed to get the :id from?

$params = array(
  //not sure what to put here, I would like to display the last 5 tweets
);

$tmhOAuth->streaming_request('POST', $method, $params, 'my_streaming_callback');
$tmhOAuth->pr($tmhOAuth);

我正在使用此https://github.com/themattharris/tmhOAuth进行身份验证,然后与 twitter api 进行交互,但我发现它非常令人困惑,因为所有这些对我来说都是非常新的。

所以基本上我只想尝试获取最新的推文,非常感谢任何帮助,因为我需要尽快完成这项工作,谢谢!:)

4

2 回答 2

1

Stream API 仅返回您连接后发布的推文。要获取以前的推文,您需要使用通用 REST API 方法: http ://dev.twitter.com/doc/get/statuses/show/:id

$tmhOAuth->request('GET', $tmhOAuth->url('1/statuses/show/$id'));
$tmhOAuth->pr(json_decode($tmhOAuth->response['response']));

$id用户ID在哪里。

于 2011-01-31T06:42:41.237 回答
0

如果你希望你可以使用这个漂亮的 jQuery 插件。它会根据您的需要做一些事情。欲了解更多信息,请访问http://tweet.seaofclouds.com/

于 2011-01-31T07:37:13.113 回答