Skip to content

Commit

Permalink
Manual request token. PHP 5.2 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
ceefour committed Oct 3, 2010
1 parent 1dd1256 commit d772f75
Showing 1 changed file with 34 additions and 14 deletions.
48 changes: 34 additions & 14 deletions Yahoo/Messenger/Engine.php
Expand Up @@ -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'];
Expand All @@ -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';
Expand Down Expand Up @@ -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'];
Expand All @@ -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'];
Expand Down Expand Up @@ -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'];
Expand All @@ -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'];
Expand All @@ -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'];
Expand All @@ -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'];
Expand All @@ -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'];
Expand All @@ -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'];
Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -462,14 +462,34 @@ 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)
$requestToken = trim(str_replace('RequestToken=', '', $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
Expand Down

0 comments on commit d772f75

Please sign in to comment.