Esempio n. 1
0
highlight_file(__FILE__);
?>
</div>

<hr>

<h2>Generate the authorization link</h2>
<?php 
echo $twitterObjUnAuth->getAuthenticateUrl();
?>

<hr>

<h2>Verify credentials</h2>
<?php 
$creds = $twitterObj->get('/account/verify_credentials.json');
?>
<pre>
<?php 
print_r($creds->response);
?>
</pre>

<hr>

<h2>Post status</h2>
<?php 
$status = $twitterObj->post('/statuses/update.json', array('status' => 'This a simple test from twitter-async at ' . date('m-d-Y h:i:s')));
?>
<pre>
<?php 
Esempio n. 2
0
// query and store firefox download stats
curl_setopt($ch, CURLOPT_URL, $stats['firefox_download_stats_url']);
list( $header, $firefox_downloads_total ) = preg_split( '/([\r\n][\r\n])\\1/', curl_exec( $ch ), 2 );
$status['download_stats'] = curl_getinfo( $ch );
echo('HTTP_CODE for FIREFOX DOWNLOAD COUNT: ' . $status['download_stats']['http_code'] . "<br>\n");

// NOTE: perhaps we need to iterate through requests: user timeline, default search
// query and store search results
curl_setopt($ch, CURLOPT_URL, $search['url']);
list( $header, $search_results ) = preg_split( '/([\r\n][\r\n])\\1/', curl_exec( $ch ), 2 );
$status['search'] = curl_getinfo( $ch );
echo('HTTP_CODE for SEARCH: ' . $status['search']['http_code'] . "<br>\n");

// query and store user timeline
// make the request
$request = $twitterObj->get($timeline['url'], array('screen_name' => $timeline['username'], 'count' => $timeline['count']));
// set the contents, create SimpleXMLElement object
$timeline_statuses_xml = new SimpleXMLElement($request->responseText);
// convert to array
$timeline_statuses_object_vars = get_object_vars($timeline_statuses_xml);
// convert to json
$timeline_statuses = json_encode($timeline_statuses_object_vars['status']);

echo('HTTP_CODE for TIMELINE: ' . $request->code . "<br>\n");

// close the curl session
curl_close( $ch );

// read and store the special_bubbles values array
$special_bubbles = array();
$special_bubbles['sb_timeline_step'] = ($config['specialbubble_timeline_step']) ? $config['specialbubble_timeline_step'] : 10;
Esempio n. 3
0
  jQuery(".heading").click(function()
  {
    jQuery(this).next(".content").slideToggle(400);
  });
});
</script>
<?php
echo "</head>";
echo "<body><center>";

echo "<div id=\"container\">  <div id=\"row\"><div id='left'>";

echo $background;
//page based
if ($page==""){
	 $creds = $twitterObj->get('/statuses/home_timeline.json', array('page' => 1));
	 $nextpage = 2;
}
else {
	$creds = $twitterObj->get('/statuses/home_timeline.json', array('page' => $page));
	
	$nextpage = ($page+1);
	$prevpage = ($page-1);
}



echo "<br/><br/><br/>";


Esempio n. 4
0
 private function searchTwitter($keywords = null, $settings = null)
 {
     $twitterObj = new EpiTwitter(WH_TWITTER_TIF_CONSUMER_KEY, WH_TWITTER_TIF_CONSUMER_SECRET);
     $params = array();
     $params['q'] = !empty($keywords) ? $keywords : "#lazyweb";
     $params['rpp'] = !empty($settings['numResults']) ? $settings['numResults'] : 15;
     $resp = $twitterObj->get('/search.json', $params);
     return $resp->responseText;
 }
Esempio n. 5
0
  // set status to ERROR if there are no contents, 200 OK otherwise
  $status = array( 'http_code' => ($contents == "false") ? 'ERROR' : 200 );
  
// proxy the contents of the parameter url
} else if ( isset($_GET['screen_names']) ) {

  // load Epi
  include_once('lib/twitteroauth/EpiCurl.php');
  include_once('lib/twitteroauth/EpiOAuth.php');
  include_once('lib/twitteroauth/EpiTwitter.php');
  include_once('lib/twitteroauth/secret.php');

  // instantiate twitter object
  $twitterObj = new EpiTwitter($consumer_key, $consumer_secret, $user_token, $user_secret_token);
  // make the request
  $request = $twitterObj->get('/users/lookup.json', array('screen_name' => $_GET['screen_names']));
  // set the contents
  $contents = json_encode($request->response);
  // set the HTTP Auth 
  $status['http_code'] = $request->code;

}

// ############################### build the response data ##################################

// Split header text into an array.
$header_text = preg_split( '/[\r\n]+/', $header );

// $data will be serialized into JSON data.
$data = array();
Esempio n. 6
0
<?php

include dirname(__FILE__) . '/../EpiCurl.php';
include dirname(__FILE__) . '/../EpiOAuth.php';
include dirname(__FILE__) . '/../EpiTwitter.php';
include dirname(__FILE__) . '/../EpiSequence.php';
$consumer_key = 'jdv3dsDhsYuJRlZFSuI2fg';
$consumer_secret = 'NNXamBsBFG8PnEmacYs0uCtbtsz346OJSod7Dl94';
$token = '25451974-uakRmTZxrSFQbkDjZnTAsxDO5o9kacz2LT6kqEHA';
$secret = 'CuQPQ1WqIdSJDTIkDUlXjHpbcRao9lcKhQHflqGE8';
$twitterObj = new EpiTwitter($consumer_key, $consumer_secret, $token, $secret);
$twitterObj->useAsynchronous(true);
?>

Test sequencing diagram of api calls

<?php 
$creds = array();
$creds[] = $twitterObj->get('/direct_messages.json');
$creds[] = $twitterObj->get('/users/suggestions.json');
$creds[] = $twitterObj->get('/statuses/public_timeline.json');
foreach ($creds as $cred) {
    $cred->responseText;
}
echo EpiCurl::getSequence()->renderAscii();
Esempio n. 7
0
<?php

/*
 * Twitter api interface
 */
chdir(dirname(__FILE__));
date_default_timezone_set('America/Los_Angeles');
include 'twitter-async/EpiCurl.php';
include 'twitter-async/EpiOAuth.php';
include 'twitter-async/EpiTwitter.php';
include 'twitter-text-php/Autolink.php';
include 'twitter-text-php/Extractor.php';
include 'twitter-text-php/HitHighlighter.php';
$key = trim(file_get_contents('secrets/tw-key'));
$sec = trim(file_get_contents('secrets/tw-sec'));
$tok = trim(file_get_contents('secrets/tw-tok'));
$toksec = trim(file_get_contents('secrets/tw-toksec'));
$tw = new EpiTwitter($key, $sec, $tok, $toksec);
$resp = $tw->get('/users/show/openphoto.json');
$status = Twitter_Autolink::create($resp->status->text)->setNoFollow(false)->addLinks();
if ($status) {
    file_put_contents('output/twitter.txt', $status . '<div class="footnote"><a href="https://twitter.com/OpenPhoto/status/' . $resp->status->id_str . '" target="_blank" rel="external">' . date('h:i \\o\\n l, M jS', strtotime($resp->status->created_at)) . '</a> from <a href="https://twitter.com/OpenPhoto" target="_blank" rel="external">Twitter</a></div>');
}
Esempio n. 8
0
function twit_init()
{
    global $consumer_key, $twpic, $username, $txt, $modSettings, $twitterObj, $realname, $userid, $url, $consumer_secret;
    $consumer_key = !empty($modSettings['tw_app_id']) ? $modSettings['tw_app_id'] : '';
    $consumer_secret = !empty($modSettings['tw_app_key']) ? $modSettings['tw_app_key'] : '';
    $token = !empty($modSettings['tw_app_token']) ? $modSettings['tw_app_token'] : '';
    $secret = !empty($modSettings['tw_app_tokensecret']) ? $modSettings['tw_app_tokensecret'] : '';
    $twitterObjUnAuth = new EpiTwitter($modSettings['tw_app_id'], $modSettings['tw_app_key']);
    try {
        $url = $twitterObjUnAuth->getAuthenticateUrl();
    } catch (Exception $e) {
        $url = '';
    }
    $twitterObj = new EpiTwitter($consumer_key, $consumer_secret, $token, $secret);
    try {
        //Try it!!!!!
        if (empty($_SESSION['twpic']) || empty($_SESSION['twusername']) || empty($_SESSION['twuserid']) || empty($_SESSION['twrealname'])) {
            if (isset($_GET['oauth_token']) || isset($_COOKIE['oauth_token']) && isset($_COOKIE['oauth_token_secret'])) {
                // user accepted access
                if (!isset($_COOKIE['oauth_token']) || !isset($_COOKIE['oauth_token_secret'])) {
                    // user comes from twitter
                    $twitterObj->setToken($_GET['oauth_token']);
                    $token = $twitterObj->getAccessToken();
                    $twitterObj->setToken($token->oauth_token, $token->oauth_token_secret);
                    setcookie('oauth_token', $token->oauth_token);
                    setcookie('oauth_token_secret', $token->oauth_token_secret);
                    $twitterInfo = $twitterObj->get('/account/verify_credentials.json');
                } else {
                    // user switched pages and came back or got here directly, stilled logged in
                    $twitterObj->setToken($_COOKIE['oauth_token'], $_COOKIE['oauth_token_secret']);
                    $twitterInfo = $twitterObj->get('/account/verify_credentials.json');
                }
                $_SESSION['twusername'] = $twitterInfo->screen_name;
                $_SESSION['twrealname'] = $twitterInfo->name;
                $_SESSION['twuserid'] = $twitterInfo->id;
                $_SESSION['twpic'] = $twitterInfo->profile_image_url;
            } elseif (isset($_GET['denied'])) {
                // user denied access
            } else {
                // user not logged in
            }
            /*$twitterObj->setToken($_GET['oauth_token']);
                        $token = $twitterObj->getAccessToken();
                        $twitterObj->setToken($token->oauth_token, $token->oauth_token_secret);		
                        $twitterInfo = $twitterObj->get('/account/verify_credentials.json');  
            
            	        $_SESSION['twusername'] = $twitterInfo->screen_name;
                        $_SESSION['twrealname'] = $twitterInfo->name;
                        $_SESSION['twuserid'] = $twitterInfo->id;
            	        $_SESSION['twpic'] = $twitterInfo->profile_image_url;*/
        }
    } catch (EpiTwitterException $e) {
        //Catch it!!!!!
        $mes = '' . $txt['tw_app_oauthexception1'] . '<br /><br />' . $e->getMessage() . '';
        fatal_error($mes, false);
    } catch (Exception $e) {
        //Catch it!!!!!
        //Thorw it!!!!!
        $mes = '' . $txt['tw_app_oauthexception2'] . '<br /><br />' . $e->getMessage() . '';
        fatal_error($mes, false);
    }
    $username = $_SESSION['twusername'];
    $realname = $_SESSION['twrealname'];
    $userid = $_SESSION['twuserid'];
    $twpic = $_SESSION['twpic'];
}
Esempio n. 9
0
<?php

/*
 * Twitter api interface
 */
chdir(dirname(__FILE__));
date_default_timezone_set('America/Los_Angeles');
include 'twitter-async/EpiCurl.php';
include 'twitter-async/EpiOAuth.php';
include 'twitter-async/EpiTwitter.php';
include 'twitter-text-php/Autolink.php';
include 'twitter-text-php/Extractor.php';
include 'twitter-text-php/HitHighlighter.php';
$key = trim(file_get_contents('secrets/tw-key'));
$sec = trim(file_get_contents('secrets/tw-sec'));
$tok = trim(file_get_contents('secrets/tw-tok'));
$toksec = trim(file_get_contents('secrets/tw-toksec'));
$tw = new EpiTwitter($key, $sec, $tok, $toksec);
$resp = $tw->get('/favorites.json');
//var_dump($resp->response);
$output = array();
foreach ($resp as $tweet) {
    $status = Twitter_Autolink::create($tweet->text)->setNoFollow(false)->addLinks();
    $url = 'https://twitter.com/' . $tweet->user->screen_name . '/status/' . $tweet->id_str;
    $output[] = array('status' => $status, 'user' => $tweet->user->screen_name, 'url' => $url, 'profile_image' => $tweet->user->profile_image_url, 'time' => date('h:i \\o\\n l, M jS', strtotime($tweet->created_at)));
}
if (!empty($output)) {
    file_put_contents('output/twitter-favorites.json', json_encode($output));
}
Esempio n. 10
0
 function get_followers()
 {
     $twitter_obj = new EpiTwitter($this->consumer_key, $this->consumer_secret);
     $twitter_obj->setToken($this->session->userdata('oauth_token'), $this->session->userdata('oauth_token_secret'));
     return $twitter_obj->get('/followers/ids.json');
 }