From d772f7520d15072a9ebef9d030136f59d5f4d7e9 Mon Sep 17 00:00:00 2001 From: Hendy Irawan Date: Sun, 3 Oct 2010 15:22:33 +0700 Subject: [PATCH] Manual request token. PHP 5.2 support. --- Yahoo/Messenger/Engine.php | 48 +++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/Yahoo/Messenger/Engine.php b/Yahoo/Messenger/Engine.php index 48c8c72..38f42fc 100644 --- a/Yahoo/Messenger/Engine.php +++ b/Yahoo/Messenger/Engine.php @@ -66,7 +66,7 @@ public function __construct($consumer_key = '', $secret_key = '', $username = '' public function fetchRequestToken() { //prepare url - $url = $this::URL_OAUTH_DIRECT; + $url = self::URL_OAUTH_DIRECT; $url .= '?login='. $this->_config['username']; $url .= '&passwd='. $this->_config['password']; $url .= '&oauth_consumer_key='. $this->_config['consumer_key']; @@ -82,7 +82,7 @@ public function fetchRequestToken() public function fetchAccessToken() { //prepare url - $url = $this::URL_OAUTH_ACCESS_TOKEN; + $url = self::URL_OAUTH_ACCESS_TOKEN; $url .= '?oauth_consumer_key='. $this->_config['consumer_key']; $url .= '&oauth_nonce='. uniqid(rand()); $url .= '&oauth_signature='. $this->_config['secret_key']. '%26'; @@ -114,7 +114,7 @@ public function fetchAccessToken() public function fetchCrumb() { //prepare url - $url = $this::URL_YM_SESSION; + $url = self::URL_YM_SESSION; $url .= '?oauth_consumer_key='. $this->_config['consumer_key']; $url .= '&oauth_nonce='. uniqid(rand()); $url .= '&oauth_signature='. $this->_config['secret_key']. '%26'. $this->_token['access']['oauth_token_secret']; @@ -138,7 +138,7 @@ public function fetchCrumb() public function signon($status = '', $state = 0) { //prepare url - $url = $this::URL_YM_SESSION; + $url = self::URL_YM_SESSION; $url .= '?oauth_consumer_key='. $this->_config['consumer_key']; $url .= '&oauth_nonce='. uniqid(rand()); $url .= '&oauth_signature='. $this->_config['secret_key']. '%26'. $this->_token['access']['oauth_token_secret']; @@ -173,7 +173,7 @@ public function signon($status = '', $state = 0) public function signoff() { //prepare url - $url = $this::URL_YM_SESSION; + $url = self::URL_YM_SESSION; $url .= '?oauth_consumer_key='. $this->_config['consumer_key']; $url .= '&oauth_nonce='. uniqid(rand()); $url .= '&oauth_signature='. $this->_config['secret_key']. '%26'. $this->_token['access']['oauth_token_secret']; @@ -193,7 +193,7 @@ public function signoff() public function changePresence($status = '', $state = 0) { //prepare url - $url = $this::URL_YM_PRESENCE; + $url = self::URL_YM_PRESENCE; $url .= '?oauth_consumer_key='. $this->_config['consumer_key']; $url .= '&oauth_nonce='. uniqid(rand()); $url .= '&oauth_signature='. $this->_config['secret_key']. '%26'. $this->_token['access']['oauth_token_secret']; @@ -214,7 +214,7 @@ public function changePresence($status = '', $state = 0) public function sendMessage($user, $message) { //prepare url - $url = $this::URL_YM_MESSAGE; + $url = self::URL_YM_MESSAGE; $url .= '?oauth_consumer_key='. $this->_config['consumer_key']; $url .= '&oauth_nonce='. uniqid(rand()); $url .= '&oauth_signature='. $this->_config['secret_key']. '%26'. $this->_token['access']['oauth_token_secret']; @@ -237,7 +237,7 @@ public function sendMessage($user, $message) public function fetchContactList() { //prepare url - $url = $this::URL_YM_CONTACT; + $url = self::URL_YM_CONTACT; $url .= '?oauth_consumer_key='. $this->_config['consumer_key']; $url .= '&oauth_nonce='. uniqid(rand()); $url .= '&oauth_signature='. $this->_config['secret_key']. '%26'. $this->_token['access']['oauth_token_secret']; @@ -263,7 +263,7 @@ public function fetchContactList() public function addContact($user, $group = 'Friends', $message = '') { //prepare url - $url = $this::URL_YM_GROUP; + $url = self::URL_YM_GROUP; $url .= '?oauth_consumer_key='. $this->_config['consumer_key']; $url .= '&oauth_nonce='. uniqid(rand()); $url .= '&oauth_signature='. $this->_config['secret_key']. '%26'. $this->_token['access']['oauth_token_secret']; @@ -286,7 +286,7 @@ public function addContact($user, $group = 'Friends', $message = '') public function deleteContact($user, $group = 'Friends') { //prepare url - $url = $this::URL_YM_GROUP; + $url = self::URL_YM_GROUP; $url .= '?oauth_consumer_key='. $this->_config['consumer_key']; $url .= '&oauth_nonce='. uniqid(rand()); $url .= '&oauth_signature='. $this->_config['secret_key']. '%26'. $this->_token['access']['oauth_token_secret']; @@ -319,7 +319,7 @@ public function responseContact($user, $accept = true, $message = '') } //prepare url - $url = $this::URL_YM_BUDDYREQUEST; + $url = self::URL_YM_BUDDYREQUEST; $url .= '?oauth_consumer_key='. $this->_config['consumer_key']; $url .= '&oauth_nonce='. uniqid(rand()); $url .= '&oauth_signature='. $this->_config['secret_key']. '%26'. $this->_token['access']['oauth_token_secret']; @@ -362,7 +362,7 @@ public function responseContact($user, $accept = true, $message = '') public function fetchNotification($seq = 0) { //prepare url - $url = $this::URL_YM_NOTIFICATION; + $url = self::URL_YM_NOTIFICATION; $url .= '?oauth_consumer_key='. $this->_config['consumer_key']; $url .= '&oauth_nonce='. uniqid(rand()); $url .= '&oauth_signature='. $this->_config['secret_key']. '%26'. $this->_token['access']['oauth_token_secret']; @@ -396,7 +396,7 @@ public function fetchNotification($seq = 0) public function fetchLongNotification($seq = 0) { //prepare url - $url = $this::URL_YM_NOTIFICATION_LONG; + $url = self::URL_YM_NOTIFICATION_LONG; $url .= '?oauth_consumer_key='. $this->_config['consumer_key']; $url .= '&oauth_nonce='. uniqid(rand()); $url .= '&oauth_signature='. $this->_config['secret_key']. '%26'. $this->_token['access']['oauth_token_secret']; @@ -462,7 +462,7 @@ public function fetchLongNotification($seq = 0) /** * Sets the request token manually. - * @param string $requestToken + * @param string $requestToken Request token. */ public function setRequestToken($requestToken) { if (stripos($requestToken, 'RequestToken') !== false) @@ -470,6 +470,26 @@ public function setRequestToken($requestToken) { $this->_token['request'] = $requestToken; } + public function getAccessToken() { + return $this->_token['access']; + } + + /** + * Sets the access token manually. + * @param string $accessToken Access token. + */ + public function setAccessToken($accessToken) { + $this->_token['access'] = $accessToken; + } + + public function getState() { + return array('token' => $this->_token, 'ym' => $this->_ym); + } + + public function setState($state) { + $this->_token = $state['token']; + $this->_ym = $state['ym']; + } /* * fetch url using curl