php - How to use Twitter API pagination for getting user tweets -
i fetching tweets of user. need show tweets ajax pagination. how can achieve that?
https://api.twitter.com/1.1/statuses/user_timeline.json
tried
i using above link. heard max_id
, since_id
not know how use that. have tried max_id
, since_id
, collection repeating. not getting cursor response.
my code
$api_key = urlencode('*********'); // consumer key (api key) $api_secret = urlencode('***********'); // consumer secret (api secret) $auth_url = 'https://api.twitter.com/oauth2/token'; // want? $data_username = '********'; // username $data_count = 1; // number of tweets $data_url = 'https://api.twitter.com/1.1/statuses/user_timeline.json'; // api access token $api_credentials = base64_encode($api_key . ':' . $api_secret); $auth_headers = 'authorization: basic ' . $api_credentials . "\r\n" . 'content-type: application/x-www-form-urlencoded;charset=utf-8' . "\r\n"; $auth_context = stream_context_create( array( 'http' => array( 'header' => $auth_headers, 'method' => 'post', 'content' => http_build_query(array('grant_type' => 'client_credentials',)), ) ) ); $auth_response = json_decode(file_get_contents($auth_url, 0, $auth_context), true); $auth_token = $auth_response['access_token']; // tweets $data_context = stream_context_create(array('http' => array('header' => 'authorization: bearer ' . $auth_token . "\r\n",))); $datas = json_decode(file_get_contents($data_url . '?include_rts=true&count=' . $data_count . '&screen_name=' . urlencode($data_username), 0, $data_context), true); // result - want print('<pre>'); print_r($datas);
question
what values have pass getting pagination url?
thank you.
Comments
Post a Comment