Skip to content
Browse files

handle token carefully

  • Loading branch information...
1 parent bb0fb88 commit 45011b2d897a3e7e73e263d29e119cbe401facbe @clsung committed May 4, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 plurkOAuth.php
View
6 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']);

0 comments on commit 45011b2

Please sign in to comment.
Something went wrong with that request. Please try again.