我使用以下代码尝试从home_timeline中抓取推文
$tmhOAuth = new tmhOAuth(array('consumer_key' => TW_KEY,
'consumer_secret' => TW_SECRET,
'user_token' => TW_UTOKEN,
'user_secret' => TW_USECRET,
));
$code = $tmhOAuth->request('GET', $tmhOAuth->url('1.1/statuses/home_timeline', 'json'));
$ tmhOAuth来自这个库:https://github.com/themattharris/tmhOAuth
出于某种原因,只有一条推文出现,这是我最近的推文。我所有旧的推文都不可见。当我将秘密和密钥更改为另一个用户应用程序的秘密和密钥时,我有类似的问题,一些推文是可见的,而其他推文则没有。有谁知道它为什么不只是抓住所有X号最近的推文?为什么有些推文缺失?
答案 0 :(得分:0)
我下载Jimbo's API from github,然后执行以下代码
<?php
ini_set('display_errors', 1);
require_once('twjimbo/TwitterAPIExchange.php');
/** Set access tokens here - see: https://dev.twitter.com/apps/ **/
$settings = array(
'oauth_access_token' => "",
'oauth_access_token_secret' => "",
'consumer_key' => '',
'consumer_secret' => ""
);
]
$url = 'https://api.twitter.com/1.1/statuses/home_timeline.json';
$getfield = '?screen_name=anythingworkshere';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
$json = $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
echo '<pre>'; print_r(json_decode($json)); echo '</pre>';