From 45011b2d897a3e7e73e263d29e119cbe401facbe Mon Sep 17 00:00:00 2001 From: Cheng-Lung Sung Date: Fri, 4 May 2012 12:44:30 +0800 Subject: [PATCH] handle token carefully --- plurkOAuth.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plurkOAuth.php b/plurkOAuth.php index 16338d1..078efde 100644 --- a/plurkOAuth.php +++ b/plurkOAuth.php @@ -35,6 +35,7 @@ function __construct($consumer_key, $consumer_secret, } function _get_request_token() { + unset($this->token); $sapi_type = php_sapi_name(); if (substr($sapi_type, 0, 3) == 'cgi') { $content = $this->request(PLURK_REQUEST_TOKEN_PATH, null, array ( @@ -78,6 +79,7 @@ function _get_access_token() { // XXX: print_r only for your first convenient, // you should store in config.php print_r($this->access_token); + unset($this->token); $this->token = new Token( $this->access_token['oauth_token'], $this->access_token['oauth_token_secret']); @@ -106,6 +108,7 @@ function authorize($access_token = NULL, $access_secret = NULL) { $this->access_token['oauth_token_secret'] = $access_secret; return true; } else { + unset($this->access_token); $this->_get_request_token(); $sapi_type = php_sapi_name(); if (substr($sapi_type, 0, 3) == 'cgi') { @@ -123,7 +126,8 @@ function request($path, $params = null, $content = null) { $params = array_merge ($params, $this->params); else $params = $this->params; - if (isset ($this->access_token['oauth_token'])) + if (isset ($this->access_token['oauth_token']) && + isset ($this->access_token['oauth_token_secret'])) $this->token = new Token( $this->access_token['oauth_token'], $this->access_token['oauth_token_secret']);