我在网站上使用php框架CodeIgniter进行Twitter连接。问题是,在连接到Twitter并重定向到回调URL后,我总是看到这500错误。
这是我的代码:
public function callback()
{
if ( $this->input->get('oauth_token') && ($this->session->userdata('twitter_request_token') !== $this->input->get('oauth_token')) ) {
$this->reset_session();
echo 'reset session';
//redirect(base_url('/twitter/auth'));
} else {
$access_token = $this->connection->getAccessToken($this->input->get('oauth_verifier'));
/*echo '<pre>';
print_r($this->connection);
echo '</pre>';*/
if ( $this->connection->http_code == 200 ) {
$this->session->set_userdata('twitter_access_token', $access_token['oauth_token']);
$this->session->set_userdata('twitter_access_token_secret', $access_token['oauth_token_secret']);
$this->session->set_userdata('twitter_user_id', $access_token['user_id']);
$this->session->set_userdata('twitter_screen_name', $access_token['screen_name']);
$this->session->unset_userdata('twitter_request_token');
$this->session->unset_userdata('twitter_request_token_secret');
echo 'http code 200 - all is fine, user connected';
//redirect(base_url('/'));
} else {
echo 'http code not 200 - not all is fine, user not connected';
// An error occured. Add your notification code here.
//redirect(base_url('/'));
}
}
}
此时我甚至都不知道为什么这个错误会产生给我...如果我重新加载此错误的页面,那么我看到其他错误: