class TwitterOAuth in Twitter 6.3
Same name and namespace in other branches
- 7.3 twitter.lib.php \TwitterOAuth
A class to provide OAuth enabled access to the twitter API
Hierarchy
- class \Twitter
- class \TwitterOAuth
Expanded class hierarchy of TwitterOAuth
1 string reference to 'TwitterOAuth'
- twitter_fetch_user_timeline in ./
twitter.inc - Fetches a user's timeline
File
- ./
twitter.lib.php, line 347 - Classes to implement the full Twitter API
View source
class TwitterOAuth extends Twitter {
protected $signature_method;
protected $consumer;
protected $token;
public function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {
$this->signature_method = new OAuthSignatureMethod_HMAC_SHA1();
$this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
if (!empty($oauth_token) && !empty($oauth_token_secret)) {
$this->token = new OAuthConsumer($oauth_token, $oauth_token_secret);
}
}
protected function create_oauth_url($path, $format = NULL) {
if (is_null($format)) {
$format = $this->format;
}
$conf = TwitterConf::instance();
$url = 'http://' . $conf
->get('api') . '/' . $path;
if (!empty($format)) {
$url .= '.' . $this->format;
}
return $url;
}
public function get_request_token() {
$url = $this
->create_oauth_url('oauth/request_token', '');
try {
$response = $this
->auth_request($url);
} catch (TwitterException $e) {
}
parse_str($response, $token);
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
return $token;
}
public function get_authorize_url($token) {
$url = $this
->create_oauth_url('oauth/authorize', '');
$url .= '?oauth_token=' . $token['oauth_token'];
return $url;
}
public function get_authenticate_url($token) {
$url = $this
->create_oauth_url('oauth/authenticate', '');
$url .= '?oauth_token=' . $token['oauth_token'];
return $url;
}
public function get_access_token() {
$url = $this
->create_oauth_url('oauth/access_token', '');
try {
$response = $this
->auth_request($url);
} catch (TwitterException $e) {
}
parse_str($response, $token);
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
return $token;
}
public function auth_request($url, $params = array(), $method = 'GET') {
$request = OAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $params);
$request
->sign_request($this->signature_method, $this->consumer, $this->token);
switch ($method) {
case 'GET':
return $this
->request($request
->to_url());
case 'POST':
return $this
->request($request
->get_normalized_http_url(), $request
->get_parameters(), 'POST');
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Twitter:: |
protected | property | ||
Twitter:: |
protected | property | ||
Twitter:: |
protected | property | ||
Twitter:: |
protected | property | ||
Twitter:: |
public | function | Calls a twitter api resource | |
Twitter:: |
protected | function | ||
Twitter:: |
public | function | Fetch the authenticated user's friends timeline | |
Twitter:: |
protected | function | Get an array of TwitterStatus objects from an API endpoint | |
Twitter:: |
public | function | ||
Twitter:: |
protected | function | ||
Twitter:: |
public | function | Fetch the public timeline | |
Twitter:: |
protected | function | Perform a request | |
Twitter:: |
public | function | Set the username and password | |
Twitter:: |
public | function | Post a new status. | |
Twitter:: |
public | function | Returns profile information about a user. | |
Twitter:: |
public | function | Fetch a user's timeline | |
Twitter:: |
public | function | ||
TwitterOAuth:: |
protected | property | ||
TwitterOAuth:: |
protected | property | ||
TwitterOAuth:: |
protected | property | ||
TwitterOAuth:: |
public | function |
Perform an authentication required request. Overrides Twitter:: |
|
TwitterOAuth:: |
protected | function | ||
TwitterOAuth:: |
public | function | ||
TwitterOAuth:: |
public | function | ||
TwitterOAuth:: |
public | function | ||
TwitterOAuth:: |
public | function | ||
TwitterOAuth:: |
public | function |
Constructor for the Twitter class Overrides Twitter:: |