pecl_httpでtwitterのユーザータイムラインを取得する
先日のAM3:00以降のデータを取得する。
PHP
<?php
$request = new HttpRequest();
$request->setUrl('http://twitter.com/statuses/user_timeline.json');
$request->enableCookies();
$request->setOptions(array(
'timeout' => 3,
'httpauth' => 'user:passwd',
'httpauthtype' => HTTP_AUTH_BASIC,
'redirect' => 1,
'unrestrictedauth' => true,
'referer' => '',
'useragent' => 'wp_twitter API/1.0',
'compress' => true,
'encodecookies' => true,
'lastmodified' => mktime(0, 0, 3) - 60*60*24,
));
$request->setContentType('application/x-www-form-urlencoded');
$request->setMethod(HttpRequest::METH_GET);
$response = $request->send();
$json = $request->getResponseBody();
var_dump(json_decode($json));
カテゴリー: 日記