本文整理匯總了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();
}