public static function setConsumer($key, $secret) { self::$consumer_key = $key; self::$consumer_secret = $secret; }
private function build_header($tweet = false) { $consumer = TwitPic_Config::getConsumer(); $oauth = TwitPic_Config::getOAuth(); $signature = HTTP_OAuth_Signature::factory('HMAC_SHA1'); $timestamp = gmdate('U'); $nonce = uniqid(); $version = '1.0'; if (is_string($tweet)) { $params = array('oauth_consumer_key' => $consumer['key'], 'oauth_signature_method' => 'HMAC-SHA1', 'oauth_token' => $oauth['token'], 'oauth_timestamp' => $timestamp, 'oauth_nonce' => $nonce, 'oauth_version' => $version, 'status' => $tweet); $sig_text = $signature->build('POST', "http://api.twitter.com/1/statuses/update.{$this->format}", $params, $consumer['secret'], $oauth['secret']); $params['oauth_signature'] = $sig_text; } else { $params = array('oauth_consumer_key' => $consumer['key'], 'oauth_signature_method' => 'HMAC-SHA1', 'oauth_token' => $oauth['token'], 'oauth_timestamp' => $timestamp, 'oauth_nonce' => $nonce, 'oauth_version' => $version); $sig_text = $signature->build('GET', 'https://api.twitter.com/1/account/verify_credentials.json', $params, $consumer['secret'], $oauth['secret']); $params['oauth_signature'] = $sig_text; } $realm = 'http://api.twitter.com/'; $header = 'OAuth realm="' . $realm . '"'; foreach ($params as $name => $value) { $header .= ", " . HTTP_OAuth::urlencode($name) . '="' . HTTP_OAuth::urlencode($value) . '"'; } return $header; }
public static function mode() { return TwitPic_Config::mode(); }