Пример #1
0
function initData()
{
    // Twitter OAuth Config options
    //$oauth_access_token = $_SESSION['oauth_token'];
    //$oauth_access_token_secret = $_SESSION['oauth_token_secret'];
    $consumer_key = TWITTER_CONSUMER_KEY;
    $consumer_secret = TWITTER_CONSUMER_SECRET;
    $user_id = '40914973';
    $screen_name = 'Nomadingineer';
    $count = 5;
    //$twitter_url = 'search/tweets.json?geocode=9.98%2C76.28%2C5km';
    // Create a Twitter Proxy object from our twitter_proxy.php class
    $twitter_proxy = new TwitterProxy($oauth_access_token, $oauth_access_token_secret, $consumer_key, $consumer_secret, $user_id, $screen_name, $count);
    $decoded_content = $_SESSION[USER_CONTENT_KEY];
    $content = json_decode($decoded_content);
    $screen_name = $content->screen_name;
    $url = 'followers/list.json?cursor=-1&screen_name=' . $screen_name . '&skip_status=false&include_user_entities=true&count=200';
    $followers = $twitter_proxy->get($url);
    $_SESSION[FOLLOWERS_SESSION_KEY] = $followers;
}
Пример #2
0
<?php

// Report all PHP errors
error_reporting(-1);
header('Content-Type: application/json');
require_once '../classes/TwitterProxy.class.php';
$auth_filename = '../config/auth.ini';
if (!file_exists($auth_filename)) {
    echo 'Exception: auth.ini file does not exist.';
} else {
    $auth_config = parse_ini_file($auth_filename);
    // Twitter OAuth Config options
    $oauth_access_token = $auth_config['oauth_access_token'];
    $oauth_access_token_secret = $auth_config['oauth_access_token_secret'];
    $consumer_key = $auth_config['consumer_key'];
    $consumer_secret = $auth_config['consumer_secret'];
    $user_id = $_GET['user_id'];
    $count = intval($_GET['count']);
    $twitter_url = 'statuses/user_timeline.json';
    $twitter_url .= '?user_id=' . $user_id;
    $twitter_url .= '&count=' . $count;
    // Create a Twitter Proxy object from our twitter_proxy.php class
    $twitter_proxy = new TwitterProxy($oauth_access_token, $oauth_access_token_secret, $consumer_key, $consumer_secret, $user_id, $count);
    // Invoke the get method to retrieve results via a cURL request
    $tweets = $twitter_proxy->get($twitter_url);
    echo $tweets;
}
Пример #3
0
// Create a Twitter Proxy object from our twitter_proxy.php class
$twitter_proxy = new TwitterProxy($oauth_access_token, $oauth_access_token_secret, $consumer_key, $consumer_secret, $user_id, $screen_name, $count);
//get users followers_count
//$user_url = 'users/lookup.json?include_entities=false&screen_name=' . 'MilMileSecrets';
//$userInfo = $twitter_proxy->get($user_url);
//$json =  json_decode($userInfo);
$screen_name = '';
//foreach($json as $item) {
//$screen_name =  $item->screen_name;
//$follower_count = $item->followers_count;
//}
//followers request
$cursor = 0;
$furl = 'followers/list.json?screen_name=' . 'MilMileSecrets' . '&skip_status=true&include_user_entities=false';
//$numPages = $follower_count / 200;
$followers = $twitter_proxy->get($furl);
while ($cursor != -1) {
    $followers = $twitter_proxy->get($furl);
    sleep(0.5);
    $f_json = json_decode($followers);
    $fArray .= $followers;
    //echo json_encode($f_json);
    if (isset($f_json) && $f_json != '') {
        $cursor = $f_json->next_cursor;
        //var_dump($cursor);
        echo $cursor;
    }
    //echo $followers;
}
//$_SESSION[FOLLOWERS_SESSION_KEY] =$followers;
echo $fArray;