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


PHP TwitterOAuth::profile方法代碼示例

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


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

示例1: oauth

 public function oauth()
 {
     $adapter_id = $this->request->get['oa2_adapter'];
     $oauth_verification = !empty($this->request->get['oauth_verifier']);
     if ($adapter_id === 'twitter') {
         try {
             $this->initOauth();
             $oauth = new TwitterOAuth($this->getConfig('twt_consumer_key'), $this->getConfig('twt_consumer_secret'));
             if ($oauth_verification) {
                 $access_token = $oauth->getAccessToken($this->request->get['oauth_verifier'], $this->request->get['oauth_token']);
                 $profile = $oauth->profile(array('skip_status' => true));
                 if (!empty($profile->errors)) {
                     $this->vars['error'] = true;
                     $this->vars['success'] = false;
                     $this->vars['message'] = $profile->errors[0]->message;
                     return $this->out();
                 }
                 $logged = array(OAuth2_Consts::CUSTOMER_DISPLAYNAME => $profile->screen_name, OAuth2_Consts::CUSTOMER_FIRSTNAME => $profile->name, OAuth2_Consts::CUSTOMER_EXT_ID => $profile->id_str);
                 $user = $this->createCustomerAndLogin(array(), $logged);
                 if (!$user || !$this->customer->isLogged()) {
                     $this->vars['error'] = true;
                     $this->vars['success'] = false;
                     $this->vars['message'] = $this->language->get('error_retry');
                 } else {
                     $this->vars['success'] = true;
                     $this->vars['message'] = $this->language->get('success_login');
                     $this->vars['redirect'] = isset($this->session->data['redirect']) ? $this->session->data['redirect'] : $this->url->link('account/account');
                 }
             } else {
                 $oauth_callback = $this->url->link('account/social_media_login/oauth', 'oa2_adapter=twitter');
                 $request_token = $oauth->getRequestToken($oauth_callback);
                 $authorize_url = $oauth->getAuthorizeURL($request_token);
                 $this->response->redirect($authorize_url);
             }
         } catch (Exception $e) {
             $this->logException($e);
             $this->vars['error'] = true;
             $this->vars['success'] = false;
             $this->vars['message'] = $this->language->get('error_retry');
         }
     }
     return $this->out();
 }
開發者ID:rootcave,項目名稱:9livesprints-web,代碼行數:43,代碼來源:social_media_login.php


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