Fixed whitespace to standard coding conventions.
This commit is contained in:
parent
52fe579ce4
commit
8014f94c58
35 changed files with 6072 additions and 6070 deletions
|
@ -47,7 +47,7 @@ class twitter{
|
|||
var $username='';
|
||||
var $password='';
|
||||
var $user_agent='';
|
||||
|
||||
|
||||
///////////////
|
||||
//
|
||||
// I don't know if these headers have become standards yet
|
||||
|
@ -59,16 +59,16 @@ class twitter{
|
|||
var $headers=array('X-Twitter-Client: ',
|
||||
'X-Twitter-Client-Version: ',
|
||||
'X-Twitter-Client-URL: ');
|
||||
|
||||
|
||||
var $responseInfo=array();
|
||||
|
||||
|
||||
|
||||
|
||||
function twitter(){}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////
|
||||
//
|
||||
// Twitter API calls
|
||||
|
@ -91,9 +91,9 @@ class twitter{
|
|||
//
|
||||
//
|
||||
/////////////////////////////////////////
|
||||
|
||||
|
||||
// Updates the authenticating user's status.
|
||||
|
||||
|
||||
// Updates the authenticating user's status.
|
||||
// Requires the status parameter specified below.
|
||||
//
|
||||
// status. (string) Required. The text of your status update. Must not be
|
||||
|
@ -105,7 +105,7 @@ class twitter{
|
|||
$postargs = 'status='.urlencode($status);
|
||||
return $this->process($request,$postargs);
|
||||
}
|
||||
|
||||
|
||||
// Returns the 20 most recent statuses from non-protected users who have
|
||||
// set a custom user icon. Does not require authentication.
|
||||
//
|
||||
|
@ -114,12 +114,13 @@ class twitter{
|
|||
//
|
||||
function publicTimeline($sinceid=false){
|
||||
$qs='';
|
||||
if($sinceid!==false)
|
||||
if($sinceid!==false) {
|
||||
$qs='?since_id='.intval($sinceid);
|
||||
}
|
||||
$request = 'http://twitter.com/statuses/public_timeline.xml'.$qs;
|
||||
return $this->process($request);
|
||||
}
|
||||
|
||||
|
||||
// Returns the 20 most recent statuses posted in the last 24 hours from the
|
||||
// authenticating user and that user's friends. It's also possible to request
|
||||
// another user's friends_timeline via the id parameter below.
|
||||
|
@ -128,21 +129,22 @@ class twitter{
|
|||
// to return the friends_timeline. (set to false if you
|
||||
// want to use authenticated user).
|
||||
// since. (HTTP-formatted date) Optional. Narrows the returned results to just those
|
||||
// statuses created after the specified date.
|
||||
// statuses created after the specified date.
|
||||
//
|
||||
function friendsTimeline($id=false,$since=false){
|
||||
$qs='';
|
||||
if($since!==false)
|
||||
if($since!==false) {
|
||||
$qs='?since='.urlencode($since);
|
||||
|
||||
if($id===false)
|
||||
}
|
||||
|
||||
if($id===false) {
|
||||
$request = 'http://twitter.com/statuses/friends_timeline.xml'.$qs;
|
||||
else
|
||||
} else {
|
||||
$request = 'http://twitter.com/statuses/friends_timeline/'.urlencode($id).'.xml'.$qs;
|
||||
|
||||
}
|
||||
return $this->process($request);
|
||||
}
|
||||
|
||||
|
||||
// Returns the 20 most recent statuses posted in the last 24 hours from the
|
||||
// authenticating user. It's also possible to request another user's timeline
|
||||
// via the id parameter below.
|
||||
|
@ -157,16 +159,17 @@ class twitter{
|
|||
function userTimeline($id=false,$count=20,$since=false){
|
||||
$qs='?count='.intval($count);
|
||||
if($since!==false)
|
||||
$qs .= '&since='.urlencode($since);
|
||||
|
||||
if($id===false)
|
||||
$qs .= '&since='.urlencode($since);
|
||||
|
||||
if($id===false) {
|
||||
$request = 'http://twitter.com/statuses/user_timeline.xml'.$qs;
|
||||
else
|
||||
} else {
|
||||
$request = 'http://twitter.com/statuses/user_timeline/'.urlencode($id).'.xml'.$qs;
|
||||
|
||||
}
|
||||
|
||||
return $this->process($request);
|
||||
}
|
||||
|
||||
|
||||
// Returns a single status, specified by the id parameter below. The status's author
|
||||
// will be returned inline.
|
||||
//
|
||||
|
@ -184,25 +187,25 @@ class twitter{
|
|||
//
|
||||
function friends($id=false){
|
||||
if($id===false)
|
||||
$request = 'http://twitter.com/statuses/friends.xml';
|
||||
$request = 'http://twitter.com/statuses/friends.xml';
|
||||
else
|
||||
$request = 'http://twitter.com/statuses/friends/'.urlencode($id).'.xml';
|
||||
$request = 'http://twitter.com/statuses/friends/'.urlencode($id).'.xml';
|
||||
return $this->process($request);
|
||||
}
|
||||
|
||||
|
||||
// Returns the authenticating user's followers, each with current status inline.
|
||||
//
|
||||
function followers(){
|
||||
$request = 'http://twitter.com/statuses/followers.xml';
|
||||
return $this->process($request);
|
||||
}
|
||||
|
||||
|
||||
// Returns a list of the users currently featured on the site with their current statuses inline.
|
||||
function featured(){
|
||||
$request = 'http://twitter.com/statuses/featured.xml';
|
||||
return $this->process($request);
|
||||
}
|
||||
|
||||
|
||||
// Returns extended information of a given user, specified by ID or screen name as per the required
|
||||
// id parameter below. This information includes design settings, so third party developers can theme
|
||||
// their widgets according to a given user's preferences.
|
||||
|
@ -213,52 +216,54 @@ class twitter{
|
|||
$request = 'http://twitter.com/users/show/'.urlencode($id).'.xml';
|
||||
return $this->process($request);
|
||||
}
|
||||
|
||||
|
||||
// Returns a list of the direct messages sent to the authenticating user.
|
||||
//
|
||||
// since. (HTTP-formatted date) Optional. Narrows the resulting list of direct messages to just those
|
||||
// sent after the specified date.
|
||||
// sent after the specified date.
|
||||
//
|
||||
function directMessages($since=false){
|
||||
$qs='';
|
||||
if($since!==false)
|
||||
if($since!==false) {
|
||||
$qs='?since='.urlencode($since);
|
||||
}
|
||||
$request = 'http://twitter.com/direct_messages.xml'.$qs;
|
||||
return $this->process($request);
|
||||
}
|
||||
|
||||
|
||||
// Sends a new direct message to the specified user from the authenticating user. Requires both the user
|
||||
// and text parameters below.
|
||||
//
|
||||
// user. (string OR int) Required. The ID or screen name of the recipient user.
|
||||
// text. (string) Required. The text of your direct message. Be sure to URL encode as necessary, and keep
|
||||
// it under 140 characters.
|
||||
// it under 140 characters.
|
||||
//
|
||||
function sendDirectMessage($user,$text){
|
||||
$request = 'http://twitter.com/direct_messages/new.xml';
|
||||
$postargs = 'user='.urlencode($user).'&text='.urlencode($text);
|
||||
return $this->process($request,$postargs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// internal function where all the juicy curl fun takes place
|
||||
// this should not be called by anything external unless you are
|
||||
// doing something else completely then knock youself out.
|
||||
function process($url,$postargs=false){
|
||||
|
||||
|
||||
$ch = curl_init($url);
|
||||
|
||||
if($postargs !== false){
|
||||
curl_setopt ($ch, CURLOPT_POST, true);
|
||||
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postargs);
|
||||
}
|
||||
|
||||
if($this->username !== false && $this->password !== false)
|
||||
|
||||
if($this->username !== false && $this->password !== false) {
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $this->username.':'.$this->password);
|
||||
|
||||
}
|
||||
|
||||
curl_setopt($ch, CURLOPT_VERBOSE, 0);
|
||||
curl_setopt($ch, CURLOPT_NOBODY, 0);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
|
@ -268,17 +273,17 @@ class twitter{
|
|||
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
|
||||
|
||||
$this->responseInfo=curl_getinfo($ch);
|
||||
curl_close($ch);
|
||||
|
||||
|
||||
|
||||
|
||||
if(intval($this->responseInfo['http_code'])==200){
|
||||
if(class_exists('SimpleXMLElement')){
|
||||
$xml = new SimpleXMLElement($response);
|
||||
return $xml;
|
||||
}else{
|
||||
return $response;
|
||||
return $response;
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue