當前位置: 首頁>>代碼示例>>PHP>>正文


PHP oauth_client_class::GetAccessToken方法代碼示例

本文整理匯總了PHP中oauth_client_class::GetAccessToken方法的典型用法代碼示例。如果您正苦於以下問題:PHP oauth_client_class::GetAccessToken方法的具體用法?PHP oauth_client_class::GetAccessToken怎麽用?PHP oauth_client_class::GetAccessToken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在oauth_client_class的用法示例。


在下文中一共展示了oauth_client_class::GetAccessToken方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: service_social_login_naver

 public static function service_social_login_naver()
 {
     if (isset($_GET['sym-api']) && $_GET['sym-api'] == 'service-social-login-naver') {
         update_option(WSKL_PREFIX . 'sym-api-' . $_SERVER['HTTP_CLIENT_IP'], 'service-social-login-naver');
     }
     if (isset($_GET['sym-api']) && $_GET['sym-api'] == 'service-social-login-naver' || isset($_GET['code']) && get_option(WSKL_PREFIX . 'sym-api-' . $_SERVER['HTTP_CLIENT_IP']) == 'service-social-login-naver') {
         require 'home-social-login/http.php';
         require 'home-social-login/oauth_client.php';
         $client = new oauth_client_class();
         $client->debug = FALSE;
         $client->debug_http = TRUE;
         $client->server = 'Naver';
         $client->redirect_uri = site_url() . '/index.php';
         $client->client_id = get_option(wskl_get_option_name('naver_client_id'));
         $client->client_secret = get_option(wskl_get_option_name('naver_client_secret'));
         if (strlen($client->client_id) == 0 || strlen($client->client_secret) == 0) {
             wskl_sym__alert('네이버 연동키값을 확인해 주세요.');
         }
         if ($login == 'Y') {
             unset($_SESSION['OAUTH_STATE']);
             $client->ResetAccessToken();
         }
         /* API permissions
          */
         if ($success = $client->Initialize()) {
             if ($success = $client->Process()) {
                 if (strlen($client->access_token)) {
                     $success = $client->CallAPI('https://apis.naver.com/nidlogin/nid/getUserProfile.xml', 'POST', array('mode' => 'userinfo'), array('FailOnAccessError' => TRUE), $user);
                 }
             }
             $success = $client->Finalize($success);
         }
         if ($client->exit) {
             exit;
         }
         if ($success) {
             $xml = simplexml_load_string($user);
             if ($xml->result->resultcode == '00') {
                 $client->GetAccessToken($AccessToken);
                 $mb_gubun = 'naver';
                 $mb_id = $xml->response->enc_id;
                 $mb_name = $xml->response->nickname;
                 $mb_nick = $xml->response->nickname;
                 $mb_email = $xml->response->email;
                 $token_value = $AccessToken['value'];
                 $token_refresh = $AccessToken['refresh'];
                 $token_secret = '';
                 //$client->ResetAccessToken();
                 if (!trim($mb_id) || !trim($token_value)) {
                     wskl_sym__alert("정보가 제대로 넘어오지 않아 오류가 발생했습니다.");
                 }
                 $token_array = urlencode(static::encryptIt($mb_gubun . '|' . substr(str_replace('|', '', $mb_id), 0, 18) . '|' . $mb_name . '|' . $mb_nick . '|' . $mb_email));
                 $redirect_url = '/?sym-api=process-social-login&token=' . $token_array;
                 wp_redirect($redirect_url);
                 exit;
             } else {
                 $error = htmlspecialchars($xml->result->resultcode);
                 alert_close($error);
             }
         } else {
             $error = htmlspecialchars($client->error);
             alert_close($error);
         }
     }
 }
開發者ID:EricKim65,項目名稱:woosym-korean-localization,代碼行數:65,代碼來源:class-social-login.php


注:本文中的oauth_client_class::GetAccessToken方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。