Esempio n. 1
0
function twitterLogin()
{
    global $consumer_key, $consumer_secret;
    if (!$consumer_key || !$consumer_secret) {
        die('Please enter your consumer key/secret!');
    }
    if (isset($_GET['oauth_token'])) {
        twitterCallback();
    }
    $twitterObj = new EpiTwitter($consumer_key, $consumer_secret);
    $url = $twitterObj->getAuthorizationUrl();
    // Customise your login link here
    echo "<a href='{$url}'><img src=\"https://si0.twimg.com/images/dev/buttons/sign-in-with-twitter-l.png\" /></a>";
}
Esempio n. 2
0
<?php

session_start();
include 'lib/EpiCurl.php';
include 'lib/EpiOAuth.php';
include 'lib/EpiTwitter.php';
$consumer_key = 'J3mABonVpWurL6u2ASW66Q';
$consumer_secret = 'Ykv84j7F0DAC2e4Dl7fsOKncYCgNgwnJuxYXvhow4';
$twitterObj = new EpiTwitter($consumer_key, $consumer_secret);
$error = null;
$login = '******' . $twitterObj->getAuthorizationUrl() . '"><img src="img/sign.png"/></a>';
if (isset($_GET['oauth_token']) || isset($_SESSION['oauth_token']) && isset($_SESSION['oauth_token_secret'])) {
    //Acceso
    if (!isset($_SESSION['oauth_token']) || !isset($_SESSION['oauth_token_secret'])) {
        //Viene de twitter
        $twitterObj->setToken($_GET['oauth_token']);
        $token = $twitterObj->getAccessToken();
        $_SESSION['oauth_token'] = $token->oauth_token;
        $_SESSION['oauth_token_secret'] = $token->oauth_token_secret;
        $twitterObj->setToken($token->oauth_token, $token->oauth_token_secret);
    } else {
        //Ya nos dio acceso
        $twitterObj->setToken($_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
    }
    $user = $twitterObj->get_accountVerify_credentials();
    $datos = "Bienvenido {$user->name}! Tienes {$user->followers_count} seguidores y te encuentras en {$user->location}";
} elseif (isset($_GET['denied'])) {
    $error = 'Debes permitir acceso a tu cuenta de twitter';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
Esempio n. 3
0
}
require_once $C->INCPATH . 'classes/class_EpiTwitter.php';
if (!isset($_SESSION['TWITTER_CONNECTED'])) {
    $_SESSION['TWITTER_CONNECTED'] = FALSE;
}
if ($_SESSION['TWITTER_CONNECTED'] && !$_SESSION['TWITTER_CONNECTED']->id) {
    $_SESSION['TWITTER_CONNECTED'] = FALSE;
}
if (isset($_GET['oauth_token'], $_SESSION['twitter_tmp_token'], $_SESSION['twitter_tmp_redirectto']) && $_GET['oauth_token'] == $_SESSION['twitter_tmp_token']) {
    $_SESSION['TWITTER_CONNECTED'] = FALSE;
    $twitterObj = new EpiTwitter($C->TWITTER_CONSUMER_KEY, $C->TWITTER_CONSUMER_SECRET);
    $twitterObj->setToken($_GET['oauth_token']);
    $token = $twitterObj->getAccessToken();
    $twitterObj->setToken($token->oauth_token, $token->oauth_token_secret);
    $twitterInfo = $twitterObj->get_accountVerify_credentials();
    $userinfo = (object) $twitterInfo->response;
    if ($userinfo && $userinfo->id) {
        $_SESSION['TWITTER_CONNECTED'] = $userinfo;
    }
    $redir = $_SESSION['twitter_tmp_redirectto'];
    unset($_SESSION['twitter_tmp_token']);
    unset($_SESSION['twitter_tmp_redirectto']);
    $this->redirect($redir);
    exit;
}
$twitterObj = new EpiTwitter($C->TWITTER_CONSUMER_KEY, $C->TWITTER_CONSUMER_SECRET);
$redir = $twitterObj->getAuthorizationUrl();
$token = preg_replace('/^(.*)\\?oauth\\_token\\=(.*)$/iuU', '$2', $redir);
$_SESSION['twitter_tmp_token'] = $token;
$_SESSION['twitter_tmp_redirectto'] = isset($_GET['backto']) ? trim($_GET['backto']) : '/home';
$this->redirect($redir);
Esempio n. 4
0
    @setcookie('oauth_token', $token->oauth_token);
    @setcookie('oauth_token_secret', $token->oauth_token_secret);
    echo '<div id="classifyBox">';
    echo '<h1>L-LDA Classifier</h1>';
    echo 'Enter a Twitter username to classify, choose a topic set, the number of pages of tweets to analyse, and then click Classify:</br />';
    echo '(Note: The more pages chosen, the longer classification will take - <span style="color:#444">currently only works in Google Chrome</span>)<br /></br />';
    echo '@<input type="text" id="usernameInput" size=20></input>	';
    echo '<select id="apiSelect"><option>Alchemy</option><option>OpenCalais</option><option>Textwise</option></select>	';
    echo '<input type="text" id="pagesInput" size=3 value="1"></input>	';
    echo '<a id="classify" href="#" onclick="llda()">Classify</a></br /><br />';
    echo '</div>';
} else {
    echo '<div id="signinInstructions">';
    echo 'To use TweetLabel, please authenticate via Twitter.';
    echo '<br /><br />';
    echo '<a id="signin" href="' . $twitterObj->getAuthorizationUrl() . '"><img src="signin.png" /></a>';
    echo '</div>';
}
?>
			<div id="results"></div>
			<div id="pie"></div>
			<div id="interactive"></div>
			<h1>Geolocated Twitter Dataset Classifications</h1>
			(Hover over a user for more detailed information)<br /><br />
			<div id="mapContainer">
				<div id="map_canvas" style="width:600px; height:400px;"></div>
				<a name="undermap"></a>
				<br />Classification Type: 
				<a href="#undermap" onclick="alchemy()">Alchemy</a> - 
				<a href="#undermap" onclick="calais()">OpenCalais</a> - 
				<a href="#undermap" onclick="textwise()">Textwise</a>
Esempio n. 5
0
<?php

include 'EpiCurl.php';
include 'EpiOAuth.php';
include 'EpiTwitter.php';
include 'secret.php';
$twitterObj = new EpiTwitter($consumer_key, $consumer_secret);
echo '<a href="' . $twitterObj->getAuthorizationUrl() . '">Authorize with Twitter</a>';
?>

Esempio n. 6
0
<?php

session_start();
include 'EpiCurl.php';
include 'EpiOAuth.php';
include 'EpiTwitter.php';
include 'secret.php';
$twitterObj = new EpiTwitter($consumer_key, $consumer_secret);
$oauth_token = $_GET['oauth_token'];
if ($oauth_token == '') {
    $url = $twitterObj->getAuthorizationUrl();
    echo "<div style='width:200px;margin-top:200px;margin-left:auto;margin-right:auto'>";
    echo "<a href='{$url}'>Sign In with Twitter</a>";
    echo "</div>";
} else {
    $twitterObj->setToken($_GET['oauth_token']);
    $token = $twitterObj->getAccessToken();
    $twitterObj->setToken($token->oauth_token, $token->oauth_token_secret);
    $_SESSION['ot'] = $token->oauth_token;
    $_SESSION['ots'] = $token->oauth_token_secret;
    $twitterInfo = $twitterObj->get_accountVerify_credentials();
    $twitterInfo->response;
    $username = $twitterInfo->screen_name;
    $profilepic = $twitterInfo->profile_image_url;
    include 'update.php';
}
if (isset($_POST['submit'])) {
    $msg = $_REQUEST['tweet'];
    $twitterObj->setToken($_SESSION['ot'], $_SESSION['ots']);
    $update_status = $twitterObj->post_statusesUpdate(array('status' => $msg));
    $temp = $update_status->response;
Esempio n. 7
0
<html>
<head>
    <title>Superchat</title>
</head>
<body>
<?php 
require_once 'EpiTwitter/TwitterConfig.php';
require_once 'EpiTwitter/EpiCurl.php';
require_once 'EpiTwitter/EpiOAuth.php';
require_once 'EpiTwitter/EpiTwitter.php';
require_once 'EpiTwitter/EpiSequence.php';
$twitterObj = new EpiTwitter($consumer_key, $consumer_secret);
$TwitterLoginUrl = $twitterObj->getAuthorizationUrl();
echo $TwitterLoginUrl;
header("Location: " . $TwitterLoginUrl);
?>
</body>
</html>
Esempio n. 8
0
 public function executeLoginTwitter()
 {
     $twitter = new EpiTwitter(sfConfig::get('app_twitter_consumer_key'), sfConfig::get('app_twitter_consumer_secret'));
     header('Location:' . $twitter->getAuthorizationUrl());
     exit;
 }
Esempio n. 9
0
 private function authenticateUser()
 {
     global $wgServer;
     $twitterObj = new EpiTwitter(WH_TWITTER_TIF_CONSUMER_KEY, WH_TWITTER_TIF_CONSUMER_SECRET);
     $twitterObj->setCallback($wgServer . '/' . TWITTER_REPLIER_SPECIAL_PAGE);
     return json_encode(array('authorizationUrl' => $twitterObj->getAuthorizationUrl()));
 }
 /**
  *
  *
  * @return array
  */
 function twitter()
 {
     App::import("Vendor", "Users.twitter/EpiCurl");
     App::import("Vendor", "Users.twitter/EpiOAuth");
     App::import("Vendor", "Users.twitter/EpiTwitter");
     $twitterObj = new EpiTwitter(TWITTER_APP_ID, TWITTER_SECRET);
     $response = array();
     $response['url'] = $twitterObj->getAuthorizationUrl();
     if (isset($_GET['oauth_token'])) {
         $twitterObj->setToken($_GET['oauth_token']);
         $token = $twitterObj->getAccessToken();
         $twitterObj->setToken($token->oauth_token, $token->oauth_token_secret);
         $_SESSION['ot'] = $token->oauth_token;
         $_SESSION['ots'] = $token->oauth_token_secret;
         $user_profile = $twitterObj->get_accountVerify_credentials()->response;
         $twtToken = $token->oauth_token;
         $twtSecret = $token->oauth_token_secret;
     }
     $response['user_profile'] = isset($user_profile) ? $user_profile : '';
     $response['user_profile']['accessToken'] = isset($twtToken) ? $twtToken : '';
     $response['user_profile']['accessSecret'] = isset($twtSecret) ? $twtSecret : '';
     return $response;
 }
Esempio n. 11
0
        <div>
          <label for="search">For</label>
          <input type="text" id="search" name="search" placeholder="search term" value="<?php 
echo $search;
?>
" />
        </div>
      </fieldset>
    </article>
    <div id="worm-and-bird" class="showinfo">
      <input type="submit" value="find it" id="findit-btn" />
        <?php 
if ($twitterInfo == null) {
    ?>
        <a id="logininfo" href="<?php 
    echo $twitterObj->getAuthorizationUrl();
    ?>
">
          <span id="info"></span>
          <div id="authenticate-info">
            <p>Twitter allows only <em><strong>you</strong></em> to search within your direct messages, friends&rsquo; tweets, etc.</p>
            <p>Click here to let Twitter know we&rsquo;re authentically searching on your behalf.</p>
          </div>
          <span id="authenticate-button" class="button">Authenticate with <span class="twitter-logo">Twitter</span></span>
        </a>
        <?php 
} else {
    ?>
        <span id="authenticate-button" class="button"><strong>@<?php 
    echo $twitterInfo->screen_name;
    ?>
Esempio n. 12
0
$mentions = null;
$timeline = null;
if ($_COOKIE['token'] && file_exists('oauth/' . $_COOKIE['token'])) {
    $username = file_get_contents('oauth/' . $_COOKIE['token']);
    $userToken = $_COOKIE['token'];
    $userSecret = file_get_contents('oauth/' . $username . '-sec');
    $twitterObj->setToken($userToken, $userSecret);
    $twitterInfo = $twitterObj->get_accountVerify_credentials();
    // access keys directly
    if (!$twitterInfo->screen_name) {
        // reset
        $twitterObj = new EpiTwitter(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET);
        $twitterInfo = null;
    }
    if ($twitterInfo && isset($_GET['status']) && $_GET['status']) {
        $status_id = $_GET['status'];
        if (preg_match('/status\\/(\\d+)/', $status_id, $matches)) {
            $status_id = $matches[1];
        }
        $method = "get_statusesShow" . $status_id;
        $raw_status = $twitterObj->{$method}();
        $status = $linkify->run($raw_status->response['text']);
        $method = "get_statusesMentions";
        $mentions = $twitterObj->{$method}(array('count' => 200));
    }
}
if ($twitterInfo == null) {
    echo '<a href="' . $twitterObj->getAuthorizationUrl() . '">auth required</a>';
} else {
    echo "You're already authenticated, go back to <a href=\"/\">Snap Bird</a> to search with friends";
}
Esempio n. 13
0
<?php

$include_path = ini_get('include_path');
ini_set('include_path', '/home/juliomiyares/jittr.com/jittr/gameon/classes' . ':' . $include_path);
require_once 'config.class.php';
require_once 'goutility.class.php';
require_once 'go_usersettings.class.php';
require_once 'EpiCurl.php';
require_once 'EpiOAuth.php';
require_once 'EpiTwitter.php';
require_once 'secret.php';
$twitterObj = new EpiTwitter($consumer_key, $consumer_secret);
$return = $twitterObj->getAuthorizationUrl();
header("Location:" . $twitterObj->getAuthorizationUrl());
?>

Esempio n. 14
0
<?php

include 'epi_curl.php';
include 'epi_o_auth.php';
include 'epi_twitter.php';
include 'secret.php';
$twitterObj = new EpiTwitter($consumer_key, $consumer_secret);
echo '<a href="' . $twitterObj->getAuthorizationUrl() . '">Add Twitter account</a>';
?>

Esempio n. 15
0
 /**
  * Setup Twitter client connection details.
  *
  * @access public
  * @since 2.0
  * @param string $username Twitter username
  * @param string $password Twitter password
  * @param string $user_agent Unique identifying user agent that identifies the App you're building. Include an email address that Twitter can use to reach you
  * @param array $send_headers Additional headers to be sent to Twitter as key/value pairs
  * @param string $timezone Formatted like America/New_York
  * @return Twitter
  */
 public function __construct($consumerKey, $consumerSecret, $token = null, $tokenSecret = null, $user_agent = null, $send_headers = null, $timezone = 'America/New_York', $debug = false)
 {
     // Don't load BackPress if the class is used inside WordPress
     if (!class_exists('WP_Query')) {
         require_once 'inc/backpress/functions.core.php';
         require_once 'inc/backpress/functions.formatting.php';
         require_once 'inc/backpress/functions.bp-options.php';
         require_once 'inc/backpress/functions.plugin-api.php';
         require_once 'inc/backpress/class.wp-http.php';
         require_once 'inc/backpress/class.wp-error.php';
     }
     $this->consumerKey = $consumerKey;
     $this->consumerSecret = $consumerSecret;
     $this->token = $token != null ? $token : '';
     $this->tokenSecret = $tokenSecret != null ? $tokenSecret : '';
     $this->api_url = '';
     $this->userAgent = $userAgent ? $userAgent : 'php-twitter/2.x - To report abuse, contact ' . $_SERVER["SERVER_ADMIN"];
     $this->send_headers = $send_headers ? $send_headers : array('Expect:', 'X-Twitter-Client: ', 'X-Twitter-Client-Version: ', 'X-Twitter-Client-URL: ');
     $this->debug = $debug ? true : false;
     $this->suppress_response_code = false;
     $this->type = 'json';
     $this->timezone = date_default_timezone_set($timezone);
     $this->http = new WP_Http();
     if ($this->oauth_token == '') {
         require_once 'inc/class.oauth.php';
         $oauth = new EpiTwitter($this->consumerKey, $this->consumerSecret);
         //$oauth->userAgent = $this->user_agent;
         echo '<pre>';
         $oauth->getAuthorizationUrl();
         print_r($oauth);
         echo '</pre>';
     }
 }