当前位置: 首页>>代码示例>>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;未经允许,请勿转载。