Example #1
0
 public function CheckTWLogin()
 {
     $user = false;
     require_once ROOTPATH . "data/third_party/twitteroauth/src/TwitterOAuth.php";
     $ckey = 'K9SC8vPbbj1V86cUcSl93m2kA';
     $csecret = 'RHfA9S74g9yHPydM4DURpNZyvVm7RU0s7Ci2O070FFG5oAyBC7';
     $access_token = '279588839-8TjR5fwRhuyNySAxUZb6NZIo9w1ymTL1EJJwJE81';
     $access_token_secret = '3LOuzmGKm6HulMjWEfTYLjM20FokhJQeYD8BPJQhfcfYH';
     if ($this->input->get('oauth_token') && $this->input->get('oauth_verifier')) {
         $request_token = array();
         $request_token['oauth_token'] = $this->session->userdata('oauth_token');
         $request_token['oauth_token_secret'] = $this->session->userdata('oauth_token_secret');
         if (!$request_token['oauth_token'] || !$request_token['oauth_token_secret'] || $request_token['oauth_token'] !== $this->input->get('oauth_token')) {
             return false;
         }
         $connection = new TwitterOAuth($ckey, $csecret, $request_token['oauth_token'], $request_token['oauth_token_secret']);
         $access_token = false;
         try {
             $access_token = $connection->oauth("oauth/access_token", array("oauth_verifier" => $this->input->get('oauth_verifier')));
         } catch (Exception $e) {
         }
         if (!$access_token) {
             return false;
         }
         $connection = new TwitterOAuth($ckey, $csecret, $access_token['oauth_token'], $access_token['oauth_token_secret']);
         $user = $connection->get("account/verify_credentials", array("include_email" => 'true'));
         return $user;
     }
     $connection = new TwitterOAuth($ckey, $csecret, $access_token, $access_token_secret);
     $request_token = $connection->oauth('oauth/request_token', array('oauth_callback' => base_url() . 'informados/user/twitter'));
     $url = $connection->url('oauth/authorize', array('oauth_token' => $request_token['oauth_token']));
     $this->session->set_userdata('oauth_token', $request_token['oauth_token']);
     $this->session->set_userdata('oauth_token_secret', $request_token['oauth_token_secret']);
     redirect($url);
     return false;
 }
Example #2
0
<?php

session_start();
require_once 'common.php';
// TwitterOAuth をインスタンス化
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
// コールバックURLをここでセット
$token = $connection->oauth('oauth/request_token', array('oauth_callback' => OAUTH_CALLBACK));
// callback.phpで使うのでセッションに保存
$_SESSION = array('oauth_token' => $token['oauth_token'], 'oauth_token_secret' => $token['oauth_token_secret']);
// Twitter.comの認証画面のURLを取得
$url = $connection->url('oauth/authenticate', array('oauth_token' => $token['oauth_token']));
// 認証画面へリダイレクト
header('location: ' . $url);
Example #3
0
 public function TwitterAccess()
 {
     require_once ROOTPATH . "data/third_party/twitteroauth/src/TwitterOAuth.php";
     if ($this->input->get('oauth_token') && $this->input->get('oauth_verifier')) {
         $request_token = array();
         $request_token['oauth_token'] = $this->session->userdata('oauth_token');
         $request_token['oauth_token_secret'] = $this->session->userdata('oauth_token_secret');
         if (!$request_token['oauth_token'] || !$request_token['oauth_token_secret'] || $request_token['oauth_token'] !== $this->input->get('oauth_token')) {
             $this->result = $this->type . "oauth_token inválido";
             return false;
         }
         $connection = new TwitterOAuth($this->twitter_config['ckey'], $this->twitter_config['csecret'], $request_token['oauth_token'], $request_token['oauth_token_secret']);
         $access_token = false;
         try {
             $access_token = $connection->oauth("oauth/access_token", array("oauth_verifier" => $this->input->get('oauth_verifier')));
         } catch (Exception $e) {
         }
         if (!$access_token) {
             $this->result = $this->type . "access_token inválido";
             return false;
         }
         $this->TwitterData($access_token);
         return true;
     }
     $connection = new TwitterOAuth($this->twitter_config['ckey'], $this->twitter_config['csecret'], $this->twitter_config['access_token'], $this->twitter_config['access_token_secret']);
     $request_token = $connection->oauth('oauth/request_token', array('oauth_callback' => base_url() . 'apps/social/add/twitter'));
     $url = $connection->url('oauth/authorize', array('oauth_token' => $request_token['oauth_token']));
     $this->session->set_userdata('oauth_token', $request_token['oauth_token']);
     $this->session->set_userdata('oauth_token_secret', $request_token['oauth_token_secret']);
     redirect($url);
     return false;
 }