Permalink
Browse files

Manual request token. PHP 5.2 support.

  • Loading branch information...
1 parent 1dd1256 commit d772f7520d15072a9ebef9d030136f59d5f4d7e9 @ceefour committed Oct 3, 2010
Showing with 34 additions and 14 deletions.
  1. +34 −14 Yahoo/Messenger/Engine.php
View
@@ -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,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

2 comments on commit d772f75

I have 2 problem with this code:

  1. Take up too much cpu resources 25%
  2. Maximum execution time of 30 seconds exceeded in Engine.php on line 538: $html = curl_exec($s);

How can I fix this problem?
Best regards,

Owner

ceefour replied Oct 10, 2010

@fasollafsl

Note: This is not a support forum.

I think the problem you have is not because of this commit at all. I suspect it's either curl or your Internet connection.

You can report an issue to http://github.com/yahoo/messenger-sdk-php/issues

Please sign in to comment.