public function auth()
 {
     return false;
     require_once _base_ . '/lib/lib.preference.php';
     $preference = new UserPreferences(getLogUserId());
     $pl = Get::gReq('pl', DOTY_STRING);
     switch ($pl) {
         case "twitter":
             /*	include_once  $GLOBALS['social_config']['twitter_library_path'];
             				echo $GLOBALS['social_config']['twitter_consumer'];
             
             				$to = new TwitterOAuth($GLOBALS['social_config']['twitter_consumer'], $GLOBALS['social_config']['twitter_secret']);
             				$tok = $to->getRequestToken();
             
             				$request_link = $to->getAuthorizeURL($tok);
             
             				$_SESSION['twit_oauth_request_token']        = $token = $tok['oauth_token'];
             				$_SESSION['twit_oauth_request_token_secret'] = $tok['oauth_token_secret'];
             
             				header("Location: $request_link");
             				exit; */
             $user_pref = array();
             $user_pref['twitter_key'] = $preference->getPreference('social.twitter_key');
             $user_pref['twitter_secret'] = $preference->getPreference('social.twitter_secret');
             if (empty($user_pref['twitter_key'])) {
                 $twitter = new EpiTwitter($this->conf['twitter_key'], $this->conf['twitter_secret']);
                 $aUrl = $twitter->getAuthenticateUrl();
                 header("location: " . $aUrl);
                 exit;
             } else {
                 $twitter = new EpiTwitter($this->conf['twitter_key'], $this->conf['twitter_secret'], $user_pref['twitter_key'], $user_pref['twitter_secret']);
                 // debug:
                 $userInfo = $twitter->get_accountVerify_credentials();
                 echo "Logged in as: " . $userInfo->screen_name;
             }
             break;
         case "linkedin":
             $user_pref = array();
             $user_pref['linkedin_key'] = $preference->getPreference('social.linkedin_key');
             $user_pref['linkedin_secret'] = $preference->getPreference('social.linkedin_secret');
             if (empty($user_pref['linkedin_key'])) {
                 $linkedin = new EpiLinkedin($this->conf['linkedin_key'], $this->conf['linkedin_secret']);
                 $aUrl = $linkedin->getAuthenticateUrl();
                 header("location: " . $aUrl);
                 exit;
             } else {
                 die("mm");
                 $linkedin = new EpiLinkedin($this->conf['linkedin_key'], $this->conf['linkedin_secret'], $user_pref['linkedin_key'], $user_pref['linkedin_secret']);
                 // debug:
                 $userInfo = $linkedin->get_accountVerify_credentials();
                 echo "Logged in as: " . $userInfo->screen_name;
             }
             break;
     }
 }
Esempio n. 2
0
function oauth_url()
{
    global $oauth_url;
    try {
        $twitterObj = new EpiTwitter(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET);
        $oauth_url = $twitterObj->getAuthenticateUrl();
        return $oauth_url;
    } catch (EpiOAuthException $e) {
        return $e;
    }
}
Esempio n. 3
0
    $twitterObj->setToken($oauth_token, $oauth_token_secret);
} else {
    if (isset($_GET['oauth_token'])) {
        // handle oauth callback from Twitter
        $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;
        $oauth_token = $_SESSION['ot'];
        $oauth_token_secret = $_SESSION['ots'];
    }
}
if ($oauth_token == '') {
    try {
        $url = $twitterObj->getAuthenticateUrl();
    } catch (EpiTwitterException $e) {
        echo 'We caught an EpiOAuthException';
        echo $e->getMessage();
    } catch (Exception $e) {
        echo 'We caught an unexpected Exception';
        echo $e->getMessage();
    }
    echo "<div align='right'>";
    echo "<a href='{$url}'>Sign In</a>";
    echo "</div>";
} else {
    $twitterInfo = $twitterObj->get_accountVerify_credentials();
    $user['username'] = $twitterInfo->screen_name;
    $user['profilepic'] = $twitterInfo->profile_image_url;
    $hometimeline = $twitterObj->get_statusesHome_timeline();
Esempio n. 4
0
 /**
  * Autentica con twitter, redirige a Twitter para que el usuario acepte
  * */
 public function authenticateTwitter()
 {
     try {
         $twitterObj = new \EpiTwitter($this->twitter_id, $this->twitter_secret);
         $url = $twitterObj->getAuthenticateUrl(null, array('oauth_callback' => $this->callback_url));
         header("Location: {$url}");
         exit;
     } catch (Exception $e) {
         $this->last_error = $e->getMessage() . " 1/ " . get_class($e);
         return false;
     }
     return true;
 }
Esempio n. 5
0
<?php

require_once dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__))))))) . '/wp-load.php';
require_once dirname(__FILE__) . '/EpiCurl.php';
require_once dirname(__FILE__) . '/EpiOAuth.php';
require_once dirname(__FILE__) . '/EpiTwitter.php';
$twitter_enabled = get_option('ProjectTheme_enable_twitter_login');
$consumer_key = get_option('ProjectTheme_twitter_consumer_key');
$consumer_secret = get_option('ProjectTheme_twitter_consumer_secret');
if ($twitter_enabled == "yes" && $consumer_key && $consumer_secret) {
    $twitter_api = new EpiTwitter($consumer_key, $consumer_secret);
    wp_redirect($twitter_api->getAuthenticateUrl());
    exit;
}
?>
<p>ProjectTheme has not been configured for Twitter</p>

Esempio n. 6
0
?>

<h1>Single test to verify everything works ok</h1>

<h2><a href="javascript:void(0);" onclick="viewSource();">View the source of this file</a></h2>
<div id="source" style="display:none; padding:5px; border: dotted 1px #bbb; background-color:#ddd;">
<?php 
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>
Esempio n. 7
0
 public function twitterAction()
 {
     require_once EXTERNAL_LIBRARY_PATH . '/twitter-async/EpiCurl.php';
     require_once EXTERNAL_LIBRARY_PATH . '/twitter-async/EpiOAuth.php';
     require_once EXTERNAL_LIBRARY_PATH . '/twitter-async/EpiTwitter.php';
     $auth = Zend_Auth::getInstance();
     $registry = Zend_Registry::getInstance();
     $router = Zend_Controller_Front::getInstance()->getRouter();
     $config = $registry->get('config');
     $request = $this->getRequest();
     $twitterConf = $config['services']['twitter'];
     $params = $request->getParams();
     $twitter = Ml_Model_Twitter::getInstance();
     $twitterObj = new EpiTwitter($twitterConf['key'], $twitterConf['secret']);
     $removeTwitterForm = $twitter->removeForm();
     $addTwitterForm = $twitter->addForm();
     if ($request->isPost()) {
         if ($removeTwitterForm->isValid($request->getPost())) {
             $twitter->disassociateAccount($auth->getIdentity());
         } else {
             if ($addTwitterForm->isValid($request->getPost())) {
                 $twitterAuthenticateUrl = $twitterObj->getAuthenticateUrl();
                 if (Zend_Uri::check($twitterAuthenticateUrl)) {
                     $this->_redirect($twitterAuthenticateUrl, array("exit"));
                 }
             }
         }
     }
     $twitterInfo = $twitter->getSignedUserTwitterAccount();
     if (isset($params['oauth_token']) && !is_array($twitterInfo)) {
         try {
             $twitterObj->setToken($params['oauth_token']);
             $token = $twitterObj->getAccessToken();
             $tokenArray = array('oauth_token' => $token->oauth_token, 'oauth_token_secret' => $token->oauth_token_secret);
             $twitter->associateAccount($tokenArray);
             $this->_redirect($router->assemble(array(), "accounttwitter"), array("exit"));
         } catch (Exception $e) {
             $this->view->twitterApiError = true;
         }
     }
     if (!is_array($twitterInfo)) {
         $this->view->getTwitterOauth = true;
     } else {
         //how old is the data retrieved from Twitter?
         $lastCheckDate = new Zend_Date($twitterInfo['timestamp'], Zend_Date::ISO_8601);
         if ($lastCheckDate->getTimestamp() < time() - 86400) {
             try {
                 $twitter->associateAccount(false, $twitterInfo);
                 $twitterInfo = $twitter->getSignedUserTwitterAccount();
             } catch (Exception $e) {
                 $this->view->invalidTwitterAccount = true;
             }
         }
         $this->view->twitterInfo = $twitterInfo;
     }
     $this->view->addTwitterForm = $addTwitterForm;
     $this->view->removeTwitterForm = $removeTwitterForm;
 }
Esempio n. 8
0
 case "facebook_login":
     include_once dirname(__FILE__) . '/login.facebook.oauth2.php';
     break;
 case "twitter_login":
     $social = new Social();
     $social->includeTwitterLib();
     require_once _base_ . '/lib/lib.preference.php';
     $preference = new UserPreferences(getLogUserId());
     $conf = $social->getConfig();
     $user_pref = array();
     $user_pref['twitter_key'] = $preference->getPreference('social.twitter_key');
     $user_pref['twitter_secret'] = $preference->getPreference('social.twitter_secret');
     if (!isset($_GET['back'])) {
         if (empty($user_pref['twitter_key'])) {
             $twitter = new EpiTwitter($conf['twitter_key'], $conf['twitter_secret']);
             $aUrl = $twitter->getAuthenticateUrl();
             header("location: " . $aUrl);
             exit;
         } else {
         }
     } else {
         // twitter callback
         $twitter = new EpiTwitter($conf['twitter_key'], $conf['twitter_secret']);
         $oauth_token = Get::gReq('oauth_token', DOTY_STRING);
         $twitter->setToken($oauth_token);
         $resp = $twitter->getAccessToken();
         $twitter->setToken($resp->oauth_token, $resp->oauth_token_secret);
         $user_pref['twitter_key'] = $resp->oauth_token;
         $user_pref['twitter_secret'] = $resp->oauth_token_secret;
     }
     $twitter = new EpiTwitter($conf['twitter_key'], $conf['twitter_secret'], $user_pref['twitter_key'], $user_pref['twitter_secret']);
Esempio n. 9
0
<center>


<img src=\"img/shot2.png\" alt=\"step 2 \" />

<img src=\"img/shot3.png\" alt=\"step 3\" />	
</center>
	";
	echo "</div>"; 
echo "<div id=\"container\">";

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

echo "<div class=\"statusbox\">";

echo '<a href="' . $twitterObj->getAuthenticateUrl() . '"><img src=img/signin.png border=\"0\" alt=\"retweet this\" /></a>';

echo "</div></div></div>";

?>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-2484933-8");
pageTracker._trackPageview();
} catch(err) {}</script>
<?php
echo "</center></BODY></HTML>";
 function getAuthenticateUrl()
 {
     $twitterObj = new EpiTwitter($this->consumer->key, $this->consumer->secret);
     return $twitterObj->getAuthenticateUrl();
 }
 public function oauthDisp()
 {
     // displays a set of oAuth providers
     $this->objDbSysconfig = $this->getObject('dbsysconfig', 'sysconfig');
     $show = $this->objDbSysconfig->getValue('show_twitter_auth', 'security');
     if (strtolower($show) == 'true') {
         $objIcon = $this->getObject('geticon', 'htmlelements');
         $objIcon->alt = "Sign in with Twitter";
         $this->consumer_key = $this->objDbSysconfig->getValue('twitter_consumer_key', 'security');
         $this->consumer_secret = $this->objDbSysconfig->getValue('twitter_consumer_secret', 'security');
         // create a link to log in with twitter
         $this->objEpiWrapper = $this->getObject('epiwrapper');
         $twitterObj = new EpiTwitter($this->consumer_key, $this->consumer_secret);
         $twiticon = $objIcon->getLinkedIcon($twitterObj->getAuthenticateUrl(), 'Sign-in-with-Twitter-lighter', 'png');
         $twitter = $twiticon;
         return $twitter . '<br />';
     } else {
         return NULL;
     }
 }
Esempio n. 12
0
function show_twitter_login()
{
    global $modSettings;
    if (!empty($modSettings['tw_app_enabled'])) {
        $twitterObjUnAuth = new EpiTwitter($modSettings['tw_app_id'], $modSettings['tw_app_key']);
        try {
            $url = $twitterObjUnAuth->getAuthenticateUrl();
        } catch (Exception $e) {
            $url = '';
        }
        echo '<a href="' . $url . '"><img src="' . $modSettings['tw_app_log_img'] . '" alt=""/></a>';
    }
}
Esempio n. 13
0
function twitteroauth($credentials, $options)
{
    try {
        $session =& JFactory::getSession();
        $mainframe =& JFactory::getApplication();
        $db = JFactory::getDBO();
        $db->setQuery('select p.apikey, p.secretkey as secret from #__providers p where p.name=' . $db->Quote($credentials['provider']));
        $consumer = $db->loadObject();
        $twitterObj = new EpiTwitter($consumer->apikey, $consumer->secret);
        // si no se ha iniciado el proceso de autenticacion
        $hasbegun = $session->get('twitterhasbegun');
        if (!isset($hasbegun) || $hasbegun == 'false') {
            $session->set('twitterhasbegun', 'true');
            $mainframe->redirect($twitterObj->getAuthenticateUrl());
        }
        $session->set('twitterhasbegun', 'false');
        $twitterObj->setToken($credentials['oauth_token']);
        $token = $twitterObj->getAccessToken();
        $twitterObj->setToken($token->oauth_token, $token->oauth_token_secret);
        $data = $twitterObj->get_accountVerify_credentials();
        $info = array();
        $info[EXTERNAL_ID] = $data->id;
        $info[STATUS] = Auth_SUCCESS;
        // todo: solicitar email
        $info[EMAIL] = '';
        $info[LABEL] = $info[EMAIL];
        return $info;
    } catch (EpiOAuthException $ex) {
        $info = array();
        $info[STATUS] = Auth_FAILURE;
        return $info;
    }
}
Esempio n. 14
0
 function get_auth_url()
 {
     $twitter_obj = new EpiTwitter($this->consumer_key, $this->consumer_secret);
     return $twitter_obj->getAuthenticateUrl();
 }
Esempio n. 15
0
function template_tpro()
{
    global $context, $scripturl, $modSettings, $sc, $txt;
    $twitterObjUnAuth = new EpiTwitter($modSettings['tw_app_id'], $modSettings['tw_app_key']);
    $url = $twitterObjUnAuth->getAuthenticateUrl();
    echo '
	<div class="cat_bar"> 
		<h3 class="catbg"> 
			<span class="ie6_header floatleft">
				' . $txt['twittmain11'] . '
			</span> 
		</h3> 
	</div>';
    echo '<p class="windowbg description">' . $txt['tw_app_sett_pro1'] . '</p> 
			<div class="windowbg2"> 
				<span class="topslice"><span></span></span> 
				<div class="content"> 
	       <dl class="register_form" >
		   <dt>';
    echo ' 
				<dt><label for="impf">' . $txt['tw_app_sett_pro2'] . '<div class="smalltext">' . $txt['tw_app_sett_pro3'] . '</div></label></dt>
					<dd>
					<button type="button"  onclick="javascript:window.location.href = \'' . $url, '\';">Import</button>
				</dd>
			</dl><hr />
		  <div align="center"><a href="' . $scripturl . '?action=twitter;area=usyncc;sesc=' . $sc . '" onclick="return confirm(\'' . $txt['twittprofileconfirm1'] . '\');">' . $txt['twittprofile1'] . '</a></div>
		</div>
				<span class="botslice"><span></span></span> 
			</div> ';
}