当前位置: 首页>>代码示例>>PHP>>正文


PHP TwitterOAuth::oauth方法代码示例

本文整理汇总了PHP中Abraham\TwitterOAuth\TwitterOAuth::oauth方法的典型用法代码示例。如果您正苦于以下问题:PHP TwitterOAuth::oauth方法的具体用法?PHP TwitterOAuth::oauth怎么用?PHP TwitterOAuth::oauth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Abraham\TwitterOAuth\TwitterOAuth的用法示例。


在下文中一共展示了TwitterOAuth::oauth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAccessToken

 /**
  * Generate an access token (oauth token and oauth secret) from Twitter OAuth
  *
  * @param string $oauth_token
  * @param string $oauth_verifier
  * @return array
  * @throws \Exception
  */
 protected function getAccessToken($oauth_token, $oauth_verifier)
 {
     $data_token = $this->client->oauth('oauth/access_token', array('oauth_verifier' => $oauth_verifier, 'oauth_token' => $oauth_token));
     if (!array_key_exists('oauth_token', $data_token) || !array_key_exists('oauth_token_secret', $data_token)) {
         throw new \Exception("OAuth token not confirmed");
     }
     return $data_token;
 }
开发者ID:remusb,项目名称:gemini-web,代码行数:16,代码来源:ServiceTwitter.php

示例2: execute

 /**
  * @return void
  * @throws \Exception
  */
 public function execute()
 {
     $storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
     $data = $this->getRequest()->getParams();
     /* Get temporary credentials from session. */
     $request_token = [];
     $request_token['oauth_token'] = $this->scopeConfig->getValue('sama_twitterfeed/oauth/token', $storeScope);
     $request_token['oauth_token_secret'] = $this->scopeConfig->getValue('sama_twitterfeed/oauth/token_secret', $storeScope);
     /* If denied, bail. */
     if (isset($data['denied'])) {
         throw new Exception("Twitter denied permission");
     }
     /* If the oauth_token is not what we expect, bail. */
     if (isset($data['oauth_token']) && $request_token['oauth_token'] !== $data['oauth_token']) {
         throw new Exception("Unexpected Oauth token");
     }
     /* Create TwitteroAuth object with app key/secret and token key/secret from default phase */
     $connection = new TwitterOAuth($this->_oAuthkey, $this->_oAuthsecret, $request_token['oauth_token'], $request_token['oauth_token_secret']);
     /* Request access tokens from twitter */
     $access_token = $connection->oauth("oauth/access_token", array("oauth_verifier" => $data['oauth_verifier']));
     /* If HTTP response is 200 continue otherwise send to connect page to retry */
     if (200 == $connection->getLastHttpCode()) {
         $this->_objectManager->get('Magento\\Framework\\App\\MutableScopeConfig')->setValue('sama_twitterfeed/oauth/access_token', $access_token);
         $this->_objectManager->get('Magento\\Framework\\App\\MutableScopeConfig')->setValue('sama_twitterfeed/oauth/token_secret', null);
         $this->_objectManager->get('Magento\\Framework\\App\\MutableScopeConfig')->setValue('sama_twitterfeed/oauth/token', null);
     } else {
         throw new Exception("Twitter Oauth API status code: {$connection->getLastHttpCode()}");
     }
     return;
 }
开发者ID:sandermangel,项目名称:magento2-twitterfeed,代码行数:34,代码来源:Callback.php

示例3: _callbackFlow

 private function _callbackFlow()
 {
     // 不正認証防止用に認証リクエスト用トークンをチェック
     if ($_GET['oauth_token'] !== $_SESSION['tmp_twitter_oauth_token']) {
         echo "Invalid Token!";
         exit;
     }
     // twitterのユーザー情報の取得
     $conn = new TwitterOAuth(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, $_SESSION['tmp_twitter_oauth_token'], $_SESSION['tmp_twitter_oauth_token_secret']);
     $tokens = $conn->oauth('oauth/access_token', ['oauth_verifier' => $_GET['oauth_verifier']]);
     //取得したtwitterユーザー情報をDBに登録もしくは更新
     $user = new \App\Model\User();
     if ($user->existsTwitterUser($tokens['user_id'])) {
         if (!$user->updateTwitterUser($tokens)) {
             echo "update error!";
             exit;
         }
     } else {
         if (!$user->createTwitterUser($tokens)) {
             echo "create error!";
             exit;
         }
     }
     //ログイン処理
     session_regenerate_id(true);
     $_SESSION['user'] = $user->findTwitterUser(['tw_user_id' => $tokens['user_id']]);
     //認証リクエスト用トークンはもう使わないので消す
     unset($_SESSION['tmp_twitter_oauth_token']);
     unset($_SESSION['tmp_twitter_oauth_token_secret']);
     header('Location: ' . SITE_URL);
     exit;
 }
开发者ID:a-tagai,项目名称:login_app,代码行数:32,代码来源:AuthTwitter.php

示例4: GetFollowersIds

	function GetFollowersIds()
	{
		/*session_start();
		$connection = new TwitterOAuth("CONSUMER_KEY",
			"CONSUMER_SECRET");
		$_SESSION['oauth_token'] = $token = $request_token['oauth_token'];
		$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
		$url = $connection->getAuthorizeURL($token);

		$connection = new TwitterOAuth("CONSUMER_KEY",
			"CONSUMER_SECRET",
			$_SESSION['oauth_token'],
			$_SESSION['oauth_token_secret']);
		$access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']);
		$_SESSION['access_token'] = $access_token;

		unset($_SESSION['oauth_token']);
		unset($_SESSION['oauth_token_secret']);

		$connection = new TwitterOAuth('CONSUMER_KEY',
			'CONSUMER_SECRET',
			$access_token['oauth_token'],
			$access_token['oauth_token_secret']);

		$content = $connection->get('followers/ids');
		var_dump($content);*/

		$connection = new TwitterOAuth("CONSUMER_KEY",
			"CONSUMER_SECRET");
		$access_token = $connection->oauth("oauth/access_token",
			array("oauth_verifier" => 'CONSUMER_KEY'));
		var_dump($access_token);
	}
开发者ID:ballanar666,项目名称:tvp-lab8,代码行数:33,代码来源:twiapi.php

示例5: getAuthorizationUrl

 public function getAuthorizationUrl(array $options = [])
 {
     $connection = new TwitterOAuth($this->clientId, $this->clientSecret);
     $request_token = $connection->oauth('oauth/request_token', array('oauth_callback' => $this->redirectUri));
     $options["session"]->write('twitter.request_token', $request_token);
     $url = $connection->url('oauth/authenticate', array('oauth_token' => $request_token['oauth_token']));
     return $url;
 }
开发者ID:kukiwasabi,项目名称:oauth2-twitter,代码行数:8,代码来源:Twitter.php

示例6: getAccessToken

 public function getAccessToken()
 {
     if (!isset($_SESSION['access_token']) && !isset($_SESSION['access_token_secret'])) {
         $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_COOKIE['oauth_token'], $_COOKIE['oauth_token_secret']);
         $access_token = $connection->oauth('oauth/access_token', array('oauth_verifier' => $_GET['oauth_verifier']));
         $_SESSION['access_token'] = $access_token['oauth_token'];
         $_SESSION['access_token_secret'] = $access_token['oauth_token_secret'];
     }
 }
开发者ID:kriby,项目名称:twitter_collage,代码行数:9,代码来源:Authorization.php

示例7: GenerateLoginLink

 function GenerateLoginLink()
 {
     $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
     $request_token = $connection->oauth('oauth/request_token', array('oauth_callback' => OAUTH_CALLBACK));
     $_SESSION['oauth_token'] = $request_token['oauth_token'];
     $_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
     $url = $connection->url('oauth/authorize', array('oauth_token' => $request_token['oauth_token']));
     return $url;
 }
开发者ID:thinkingboxmedia,项目名称:ShareAPI,代码行数:9,代码来源:twitter_verify.php

示例8: getUserInformation

 public function getUserInformation($user_oauth_token, $user_oauth_verifier)
 {
     $connection = new TwitterOAuth($this->consumer_key, $this->consumer_secret, $user_oauth_token, $_SESSION['oauth_token_secret']);
     $access_token = $connection->oauth("oauth/access_token", ["oauth_verifier" => $user_oauth_verifier]);
     $connection2 = new TwitterOAuth($this->consumer_key, $this->consumer_secret, $access_token['oauth_token'], $access_token['oauth_token_secret']);
     $user = $connection2->get("account/verify_credentials");
     $this->response['data'] = ['imagePath' => str_replace('_normal', '', $user->profile_image_url), 'imageThumb' => $user->profile_image_url, 'twitterId' => $user->id, 'name' => $user->name];
     return $this->response;
 }
开发者ID:silverwolfx10,项目名称:tcc-uhealth,代码行数:9,代码来源:Twitter.php

示例9: twitter

 public function twitter()
 {
     $connection = new TwitterOAuth(Config::get('twitter.appid'), Config::get('twitter.secret'));
     $request_token = $connection->oauth('oauth/request_token', array('oauth_callback' => Config::get('twitter.callback')));
     $_SESSION['login_type'] = "twitter";
     $_SESSION['oauth_token'] = $request_token['oauth_token'];
     $_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
     $url = $connection->url('oauth/authorize', array('oauth_token' => $request_token['oauth_token']));
     return redirect($url);
 }
开发者ID:CoffeeOwl17,项目名称:Cruises-Booking,代码行数:10,代码来源:login_controller.php

示例10: callbackTwitter

 public function callbackTwitter()
 {
     if (isset($_REQUEST['oauth_verifier'], $_REQUEST['oauth_token']) && $_REQUEST['oauth_token'] == Session::get('oauth_token')) {
         $request_token = [];
         $request_token['oauth_token'] = Session::get('oauth_token');
         $request_token['oauth_token_secret'] = Session::get('oauth_token_secret');
         $connection = new TwitterOAuth(config('socialpack.composer_key'), config('socialpack.composer_secret'), $request_token['oauth_token'], $request_token['oauth_token_secret']);
         $access_token = $connection->oauth("oauth/access_token", array("oauth_verifier" => $_REQUEST['oauth_verifier']));
         Session::put('access_token', $access_token);
         return redirect('/socialpacks/twitter');
     }
 }
开发者ID:jedelhu,项目名称:socialpack,代码行数:12,代码来源:SocialpackController.php

示例11: getAccessToken

 /**
  * Obtain an access token (before logging in to twitter access token).
  *
  * @see     https://dev.twitter.com/web/sign-in/implementing
  * @param   string
  * @return  mixed
  */
 public function getAccessToken($sOathVerifier)
 {
     if ($sOathVerifier) {
         $this->_initializeTwitterOauth(self::OAUTH_VERIFIER);
         $aAccessToken = $this->_oTwitterOAth->oauth('oauth/access_token', ['oauth_verifier' => $sOathVerifier]);
         if ($this->_oTwitterOAth->getLastHttpCode() === 200) {
             AppSessionHandler::i()->set('access_token', $aAccessToken);
             return $aAccessToken;
         }
     }
     return false;
 }
开发者ID:karlpatrickespiritu,项目名称:ontrack,代码行数:19,代码来源:TwitterHandler.php

示例12: _redirectFlow

 private function _redirectFlow()
 {
     $conn = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
     //リクエストトークンをセットする、コールバックURKを渡す
     $tokens = $conn->oauth('oauth/request_token', ['oauth_callback' => CALLBACK_URL]);
     // 後で利用できるようにsessionに保存する
     $_SESSION['oauth_token'] = $tokens['oauth_token'];
     $_SESSION['oauth_token_secret'] = $tokens['oauth_token_secret'];
     // redirect アカウントの利用を許可しますか?へ飛ばす
     $authorizeUrl = $conn->url('oauth/authorize', ['oauth_token' => $tokens['oauth_token']]);
     header('Location: ' . $authorizeUrl);
     exit;
 }
开发者ID:johnmanjiro,项目名称:first_app,代码行数:13,代码来源:Twitterlogin.php

示例13: getFinalToken

 public function getFinalToken($oauth_token, $oauth_verifier)
 {
     $request_token = [];
     $request_token['oauth_token'] = Session::get('oauth_token');
     $request_token['oauth_token_secret'] = Session::get('oauth_token_secret');
     if ($request_token['oauth_token'] !== $oauth_token) {
         return "Your request timed out";
     }
     $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $request_token['oauth_token'], $request_token['oauth_token_secret']);
     $access_token = $connection->oauth("oauth/access_token", ["oauth_verifier" => $oauth_verifier]);
     Session::put('access_token', $access_token);
     return "Success";
 }
开发者ID:numair1,项目名称:NumairFeestr,代码行数:13,代码来源:twitterController.php

示例14: getAccessToken

 public function getAccessToken()
 {
     $request_token = [];
     $request_token['oauth_token'] = $_SESSION['oauth_token'];
     $request_token['oauth_token_secret'] = $_SESSION['oauth_token_secret'];
     if (isset($_GET['oauth_token']) && $request_token['oauth_token'] !== $_GET['oauth_token']) {
         exit('Error: something went wrong...');
     }
     $connection = new TwitterOAuth(self::CONSUMER_KEY, self::CONSUMER_SECRET, $request_token['oauth_token'], $request_token['oauth_token_secret']);
     $access_token = $connection->oauth('oauth/access_token', array("oauth_verifier" => $_GET['oauth_verifier']));
     if (empty($access_token)) {
         exit('Error: invalid access token....');
     }
     return $access_token;
 }
开发者ID:AlexSoicalap,项目名称:login_con_twitter_php,代码行数:15,代码来源:TwitterOAuthHelper.php

示例15: completeLogin

 /**
  * Completes social login. Is caled after redirect from twitter auth page
  * 
  * @param array $extrainputs List of POST/GET arguments names
  */
 public function completeLogin($extrainputs = array())
 {
     $request_token = [];
     $request_token['oauth_token'] = $this->request_token['oauth_token'];
     $request_token['oauth_token_secret'] = $this->request_token['oauth_token_secret'];
     $this->logQ('session token ' . print_r($request_token, true), 'twitter');
     $this->logQ('extra options ' . print_r($extrainputs, true), 'twitter');
     if (isset($extrainputs['oauth_token']) && $request_token['oauth_token'] !== $extrainputs['oauth_token']) {
         throw new \Exception('Twitter oauth. Somethign went wrong. No token in the session');
     }
     $connection = new TwitterOAuth($this->options['consumer_key'], $this->options['consumer_secret'], $request_token['oauth_token'], $request_token['oauth_token_secret']);
     $access_token = $connection->oauth("oauth/access_token", array("oauth_verifier" => $extrainputs['oauth_verifier']));
     $this->access_token = $access_token;
     return $this->getUserProfile();
 }
开发者ID:gelembjuk,项目名称:auth,代码行数:20,代码来源:Twitter.php


注:本文中的Abraham\TwitterOAuth\TwitterOAuth::oauth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。