예제 #1
0
 public function signin()
 {
     $oauthapp = new \YahooOAuthApplication(Ntentan::$config['social.yahoo.consumer_key'], Ntentan::$config['social.yahoo.consumer_secret'], Ntentan::$config['social.yahoo.app_id'], Ntentan::$config['social.yahoo.redirect_uri']);
     if (!isset($_REQUEST['openid_mode'])) {
         Ntentan::redirect($oauthapp->getOpenIDUrl($oauthapp->callback_url), true);
         die;
     }
     if ($_REQUEST['openid_mode'] == 'id_res') {
         $requestToken = new \YahooOAuthRequestToken($_REQUEST['openid_oauth_request_token'], '');
         $_SESSION['yahoo_oauth_request_token'] = $requestToken->to_string();
         $oauthapp->token = $oauthapp->getAccessToken($requestToken);
         $_SESSION['yahoo_oauth_access_token'] = $oauthapp->token->to_string();
     }
     $profile = $oauthapp->getProfile()->profile;
     if (is_object($profile)) {
         if (is_array($profile->emails)) {
             foreach ($profile->emails as $email) {
                 if ($email->primary == 'true') {
                     $email = $email->handle;
                     break;
                 }
             }
         }
         return array('firstname' => $profile->givenName, 'lastname' => $profile->familyName, 'key' => "yahoo_{$profile->guid}", 'avatar' => $profile->image->imageUrl, 'email' => $email, 'email_confirmed' => true);
     }
     die('Failed');
 }
예제 #2
0
 public function authencation()
 {
     $obj_token = new stdClass();
     $request_token = $_SESSION['request_token'];
     if ($request_token) {
         foreach ($request_token as $key => $value) {
             $obj_token->{$key} = $value;
         }
         $oauthapp = new YahooOAuthApplication($this->key, $this->secret, $this->appId, $this->domain);
         # Exchange request token for authorized access token
         $access_token = $oauthapp->getAccessToken($obj_token, $_REQUEST['oauth_verifier']);
         $profile = $oauthapp->getProfile();
         return $profile;
     }
 }
예제 #3
0
파일: yahoo.php 프로젝트: utopszkij/keszlet
 public function onSloginCheck()
 {
     //получение значений из сессии
     $session = JFactory::getSession();
     $request_token = unserialize($session->get('request_token'));
     $oauthapp = new YahooOAuthApplication($this->key, $this->secret, $this->app_id, $this->callback);
     $input = JFactory::getApplication()->input;
     $oauth_verifier = $input->getString('oauth_verifier', '');
     # Exchange request token for authorized access token
     $access_token = $oauthapp->getAccessToken($request_token, $oauth_verifier);
     # update access token
     $oauthapp->token = $access_token;
     # fetch user profile
     $profile = $oauthapp->getProfile();
     if (empty($profile)) {
         die('Error: profile empty');
     }
     //var_dump($profile);
     /*
     object(stdClass)#594 (1) { 
     ["profile"]=> object(stdClass)#593 (10) { 
     	["guid"]=> string(26) "YHDVXZ4H4LBJKT6NGXU5JQ537E" 
     	["ageCategory"]=> string(1) "A" 
     	["created"]=> string(20) "2014-11-24T05:48:59Z" 
     	["image"]=> object(stdClass)#592 (4) { ["height"]=> string(3) "192" 
     	["imageUrl"]=> string(56) "https://s.yimg.com/dh/ap/social/profile/profile_b192.png" 
     	["size"]=> string(7) "192x192" ["width"]=> string(3) "192" } 
     	["lang"]=> string(5) "en-US" 
     	["memberSince"]=> string(20) "2014-09-30T12:10:41Z" 
     	["nickname"]=> string(7) "Arkadiy" 
     	["profileUrl"]=> string(51) "http://profile.yahoo.com/YHDVXZ4H4LBJKT6NGXU5JQ537E" 
     	["isConnected"]=> string(5) "false" 
     	["bdRestricted"]=> string(4) "true" } } 
     */
     $returnRequest = new SloginRequest();
     $returnRequest->first_name = isset($profile->profile->givenName) ? $profile->profile->givenName : $profile->profile->nickname;
     $returnRequest->last_name = isset($profile->profile->familyName) ? $profile->profile->familyName : '';
     $returnRequest->email = isset($profile->profile->emails->handle) ? $profile->profile->emails->handle : '';
     $returnRequest->id = isset($profile->profile->guid) ? $profile->profile->guid : '';
     $returnRequest->real_name = isset($profile->profile->givenName) ? $profile->profile->givenName : $profile->profile->nickname;
     $returnRequest->sex = isset($profile->profile->gender) ? $profile->profile->gender : '';
     $returnRequest->display_name = $profile->profile->nickname;
     $returnRequest->all_request = $profile->profile;
     return $returnRequest;
 }
</div>
<?php 
} else {
    ?>

<?php 
    if (isset($_SESSION['yahoo_oauth_request_token'])) {
        ?>
<div id="ysimpleauth-logout" class="authbar"><a href="simpleauth.php?openid_mode=cancel">Logout</a></div>
<?php 
    }
    ?>

<?php 
    // fetch latest user data
    $profile = $oauthapp->getProfile();
    $updates = $oauthapp->getUpdates(null, 0, 20);
    $connections = $oauthapp->getConnections(null, 0, 1000);
    ?>

<div id="profile" class="yui-b">
  <div class="vcard">
    <span class="fn n">
  		<a href="<?php 
    echo $profile->profileUrl;
    ?>
"  title="<?php 
    echo $profile->nickname;
    ?>
's Profile" ><img src="<?php 
    echo $profile->image->imageUrl;
예제 #5
0
 public function onSloginCheck()
 {
     //получение значений из сессии
     $session = JFactory::getSession();
     $request_token = unserialize($session->get('request_token'));
     $oauthapp = new YahooOAuthApplication($this->key, $this->secret, $this->app_id, $this->callback);
     $input = JFactory::getApplication()->input;
     $oauth_verifier = $input->getString('oauth_verifier', '');
     # Exchange request token for authorized access token
     $access_token = $oauthapp->getAccessToken($request_token, $oauth_verifier);
     # update access token
     $oauthapp->token = $access_token;
     # fetch user profile
     $profile = $oauthapp->getProfile();
     //echo '<pre>'; var_dump($profile);
     /*
     object(stdClass)#328 (1) {
       ["profile"]=>
       object(stdClass)#327 (18) {
         ["guid"]=>
         string(26) "H6KKGGLX5Z4QQFUO6JQGESGWJU"
         ["aboutMe"]=>
         string(0) ""
         ["disclosures"]=>
         array(2) {
           [0]=>
           object(stdClass)#326 (4) {
     ["acceptance"]=>
     string(1) "1"
     ["name"]=>
     string(2) "bd"
     ["seen"]=>
     string(20) "2014-03-31T12:46:55Z"
     ["version"]=>
     string(1) "1"
           }
           [1]=>
           object(stdClass)#325 (4) {
     ["acceptance"]=>
     string(1) "1"
     ["name"]=>
     string(5) "ccard"
     ["seen"]=>
     string(20) "2014-03-31T12:46:55Z"
     ["version"]=>
     string(1) "1"
           }
         }
         ["emails"]=>
         object(stdClass)#324 (3) {
           ["handle"]=>
           string(28) "*****@*****.**"
           ["id"]=>
           string(1) "1"
           ["type"]=>
           string(4) "HOME"
         }
         ["familyName"]=>
         string(22) "Седельников"
         ["gender"]=>
         string(1) "M"
         ["givenName"]=>
         string(14) "Аркадий"
         ["image"]=>
         object(stdClass)#323 (4) {
           ["height"]=>
           string(3) "192"
           ["imageUrl"]=>
           string(80) "https://socialprofiles.zenfs.com/images/ccd1f5680c57f107485ab31ee8eabb08_192.png"
           ["size"]=>
           string(7) "192x192"
           ["width"]=>
           string(3) "192"
         }
         ["interests"]=>
         array(11) {
           [0]=>
           object(stdClass)#322 (2) {
     ["declaredInterests"]=>
     string(0) ""
     ["interestCategory"]=>
     string(13) "prfFavHobbies"
           }
           [1]=>
           object(stdClass)#321 (2) {
     ["declaredInterests"]=>
     string(0) ""
     ["interestCategory"]=>
     string(11) "prfFavMusic"
           }
           [2]=>
           object(stdClass)#320 (2) {
     ["declaredInterests"]=>
     string(0) ""
     ["interestCategory"]=>
     string(12) "prfFavMovies"
           }
           [3]=>
           object(stdClass)#319 (2) {
     ["declaredInterests"]=>
     string(0) ""
     ["interestCategory"]=>
     string(18) "prfFavFutureMovies"
           }
           [4]=>
           object(stdClass)#318 (2) {
     ["declaredInterests"]=>
     string(0) ""
     ["interestCategory"]=>
     string(11) "prfFavBooks"
           }
           [5]=>
           object(stdClass)#317 (2) {
     ["declaredInterests"]=>
     string(0) ""
     ["interestCategory"]=>
     string(17) "prfFavFutureBooks"
           }
           [6]=>
           object(stdClass)#316 (2) {
     ["declaredInterests"]=>
     string(0) ""
     ["interestCategory"]=>
     string(12) "prfFavQuotes"
           }
           [7]=>
           object(stdClass)#315 (2) {
     ["declaredInterests"]=>
     string(0) ""
     ["interestCategory"]=>
     string(11) "prfFavFoods"
           }
           [8]=>
           object(stdClass)#314 (2) {
     ["declaredInterests"]=>
     string(0) ""
     ["interestCategory"]=>
     string(12) "prfFavPlaces"
           }
           [9]=>
           object(stdClass)#313 (2) {
     ["declaredInterests"]=>
     string(0) ""
     ["interestCategory"]=>
     string(18) "prfFavFuturePlaces"
           }
           [10]=>
           object(stdClass)#312 (2) {
     ["declaredInterests"]=>
     string(0) ""
     ["interestCategory"]=>
     string(11) "prfFavAelse"
           }
         }
         ["lang"]=>
         string(5) "en-US"
         ["location"]=>
         string(0) ""
         ["memberSince"]=>
         string(20) "2014-03-31T08:19:34Z"
         ["nickname"]=>
         string(14) "Аркадий"
         ["phones"]=>
         object(stdClass)#311 (3) {
           ["id"]=>
           string(2) "10"
           ["number"]=>
           string(12) "7-9059450590"
           ["type"]=>
           string(6) "MOBILE"
         }
         ["profileUrl"]=>
         string(51) "http://profile.yahoo.com/H6KKGGLX5Z4QQFUO6JQGESGWJU"
         ["timeZone"]=>
         string(19) "America/Los_Angeles"
         ["isConnected"]=>
         string(4) "true"
         ["bdRestricted"]=>
         string(4) "true"
       }
     }
     */
     if (empty($profile)) {
         die('Error: profile empty');
     }
     $returnRequest = new SloginRequest();
     $returnRequest->first_name = $profile->profile->givenName;
     $returnRequest->last_name = $profile->profile->familyName;
     $returnRequest->email = $profile->profile->emails->handle;
     $returnRequest->id = $profile->profile->guid;
     $returnRequest->real_name = $profile->profile->givenName . ' ' . $profile->profile->familyName;
     $returnRequest->sex = $profile->profile->gender;
     $returnRequest->display_name = $profile->profile->nickname;
     $returnRequest->all_request = $profile->profile;
     return $returnRequest;
 }