コード例 #1
0
ファイル: Yahoo.php プロジェクト: ntentan/social-extension
 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 fetch_request_token($oauth_request)
 {
     $http = YahooCurl::fetch($oauth_request->to_url(), array(), array(), $oauth_request->get_normalized_http_method());
     return YahooOAuthRequestToken::from_string($http['response_body']);
 }
コード例 #3
0
require_once dirname(__FILE__) . '/../common.inc.php';
$oauthapp = new YahooOAuthApplication(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_APP_ID, OAUTH_DOMAIN);
// handle openid/oauth
if (isset($_REQUEST['openid_mode'])) {
    switch ($_REQUEST['openid_mode']) {
        case 'discover':
        case 'checkid_setup':
        case 'checkid_immediate':
            // handle yahoo simpleauth popup + redirect to yahoo! open id with open app oauth request
            header('Location: ' . $oauthapp->getOpenIDUrl(isset($_REQUEST['popup']) ? $oauthapp->callback_url . '?close=true' : $oauthapp->callback_url));
            exit;
            break;
        case 'id_res':
            // validate claimed open id
            // extract approved request token from open id response
            $request_token = new YahooOAuthRequestToken($_REQUEST['openid_oauth_request_token'], '');
            $_SESSION['yahoo_oauth_request_token'] = $request_token->to_string();
            // exchange request token for access token
            $oauthapp->token = $oauthapp->getAccessToken($request_token);
            // store access token for later
            $_SESSION['yahoo_oauth_access_token'] = $oauthapp->token->to_string();
            break;
        case 'cancel':
            unset($_SESSION['yahoo_oauth_access_token']);
            unset($_REQUEST['openid_mode']);
            header('Location: ' . $oauthapp->callback_url);
            exit;
            // openid cancelled
            break;
        case 'associate':
            // openid associate user