Are there any Documentation to refer to?
On Sep 1, 1:22 am, Chris Babcock <[email protected]> wrote: > Paste Bin - pastebin.com - is our friend. > > Chris > > On Mon, 31 Aug 2009 16:17:55 -0400 > > Andrew Badera <[email protected]> wrote: > > TEXT AVALANCHE! RUN! > > > ∞ Andy Badera > > ∞ This email is: [ ] bloggable [x] ask first [ ] private > > ∞ Google me: > >http://www.google.com/search?q=(andrew+badera)+OR+(andy+badera) > > > On Mon, Aug 31, 2009 at 3:27 PM, Pj<[email protected]> wrote: > > > > Can anyone please assist me on how to use/call this API functions > > > with php? > > > > I tried > > > <?php > > > > require("new.class.php"); > > > > $twitter = new Twitter("****", "****"); > > > > $msg = $twitter->getMessages("xml"); > > > > echo "<pre>". $msg. "</pre>"; > > > > ?> > > > > And something weird displayed.. > > > thanks in advance. > > > > //////////////////////////new.class.php\\\\\\\\\\\\\\\\\\\\\\ > > > <?php > > > /** > > > * Twitter interface class > > > * Nov 26 2007 Nick Beam > > > * Bugs, comments, questions: [email protected] > > > *http://rbrw.net--http://tinydinosaur.com > > > * > > > * This is a simple interface to the Twitter API. > > > * I've tried to keep as close as possible to the real API > > > * calls (some had to be changed due to ambiguity), but all > > > * of the arguments are as they are in the official docs. > > > * > > > * Usage: > > > * $twitter = new Twitter("username", "password"); > > > * $public_timeline_xml = $twitter->getPublicTimeline("xml"); > > > * > > > * Methods: > > > * getPublicTimeline($format [, $since_id]) > > > * getFriendsTimeline($format [, $id [, $since ]]) > > > * getUserTimeline($format [, $id [, $count [, $since ]]]) > > > * showStatus($format, $id) > > > * updateStatus($status) > > > * destroyStatus($format, $id) > > > * getReplies($format [, $page ]) > > > * getFriends($format [, $id ]) > > > * getFollowers($format [, $lite ]) > > > * getFeatured($format) > > > * showUser($format [, $id [, $email ]]) > > > * getMessages($format [, $since [, $since_id [, $page ]]]) > > > * getSentMessages($format [, $since [, $since_id [, $page ]]]) > > > * newMessage($format, $user, $text) > > > * destroyMessage($format, $id) > > > * createFriendship($format, $id) > > > * destroyFriendship($format, $id) > > > * verifyCredentials([$format]) > > > * endSession() > > > * getArchive($format [, $page ]) > > > * getFavorites($format [, $id [, $page ]]) > > > * createFavorite($format, $id) > > > * destroyFavorite($format, $id) > > > * lastStatusCode() > > > * lastAPICall() > > > */ > > > > class Twitter { > > > /* Username:password format string */ > > > private $credentials; > > > > /* Contains the last HTTP status code returned */ > > > private $http_status; > > > > /* Contains the last API call */ > > > private $last_api_call; > > > > /* Twitter class constructor */ > > > function Twitter($username, $password) { > > > $this->credentials = sprintf("%s:%s", $username, > > > $password); } > > > > function getPublicTimeline($format, $since_id = 0) { > > > $api_call = > > > sprintf("http://twitter.com/statuses/public_timeline. %s", $format); > > > if ($since_id > 0) { > > > $api_call .= sprintf("?since_id=%d", > > > $since_id); } > > > return $this->APICall($api_call); > > > } > > > > function getFriendsTimeline($format, $id = NULL, $since = > > > NULL) { if ($id != NULL) { > > > $api_call = > > > sprintf("http://twitter.com/statuses/friends_timeline/%s.%s", $id, > > > $format); } > > > else { > > > $api_call = > > > sprintf("http://twitter.com/statuses/friends_timeline. %s", > > > $format); } > > > if ($since != NULL) { > > > $api_call .= sprintf("?since=%s", > > > urlencode($since)); } > > > return $this->APICall($api_call, true); > > > } > > > > function getUserTimeline($format, $id = NULL, $count = 20, > > > $since = NULL) { > > > if ($id != NULL) { > > > $api_call = > > > sprintf("http://twitter.com/statuses/user_timeline/%s. %s", $id, > > > $format); } > > > else { > > > $api_call = > > > sprintf("http://twitter.com/statuses/user_timeline.%s", $format); > > > } > > > if ($count != 20) { > > > $api_call .= sprintf("?count=%d", $count); > > > } > > > if ($since != NULL) { > > > $api_call .= sprintf("%ssince=%s", > > > (strpos($api_call, "?count=") === false) ? "?" : "&", > > > urlencode($since)); } > > > return $this->APICall($api_call, true); > > > } > > > > function showStatus($format, $id) { > > > $api_call = > > > sprintf("http://twitter.com/statuses/show/%d.%s", $id, $format); > > > return $this->APICall($api_call); > > > } > > > > function updateStatus($status) { > > > $status = > > > urlencode(stripslashes(urldecode($status))); $api_call = > > > sprintf("http://twitter.com/statuses/update.xml?status=%s", > > > $status); return $this->APICall($api_call, true, true); > > > } > > > > function getReplies($format, $page = 0) { > > > $api_call = > > > sprintf("http://twitter.com/statuses/replies.%s", $format); > > > if ($page) { > > > $api_call .= sprintf("?page=%d", $page); > > > } > > > return $this->APICall($api_call, true); > > > } > > > > function destroyStatus($format, $id) { > > > $api_call = > > > sprintf("http://twitter.com/statuses/destroy/%d.%s", $id, $format); > > > return $this->APICall($api_call, true); > > > } > > > > function getFriends($format, $id = NULL) { > > > // take care of the id parameter > > > if ($id != NULL) { > > > $api_call = > > > sprintf("http://twitter.com/statuses/friends/%s.%s", $id, $format); > > > } > > > else { > > > $api_call = > > > sprintf("http://twitter.com/statuses/friends.%s", $format); > > > } > > > return $this->APICall($api_call, true); > > > } > > > > function getFollowers($format, $lite = NULL) { > > > $api_call = > > > sprintf("http://twitter.com/statuses/followers.%s%s", $format, > > > ($lite) ? "?lite=true" : NULL); return $this->APICall($api_call, > > > true); } > > > > function getFeatured($format) { > > > $api_call = > > > sprintf("http://twitter.com/statuses/featured.%s", $format); > > > return $this->APICall($api_call); > > > } > > > > function showUser($format, $id, $email = NULL) { > > > if ($email == NULL) { > > > $api_call = > > > sprintf("http://twitter.com/users/show/%s.%s", $id, $format); > > > } > > > else { > > > $api_call = > > > sprintf("http://twitter.com/users/show.xml?email=%s", $email); > > > } > > > return $this->APICall($api_call, true); > > > } > > > > function getMessages($format, $since = NULL, $since_id = 0, > > > $page = 1) { > > > $api_call = > > > sprintf("http://twitter.com/direct_messages.%s", $format); > > > if ($since != NULL) { > > > $api_call .= sprintf("?since=%s", > > > urlencode($since)); } > > > if ($since_id > 0) { > > > $api_call .= sprintf("%ssince_id=%d", > > > (strpos($api_call, "?since") === false) ? "?" : "&", $since_id); > > > } > > > if ($page > 1) { > > > $api_call .= sprintf("%spage=%d", > > > (strpos($api_call, "?since") === false) ? "?" : "&", $page); > > > } > > > return $this->APICall($api_call, true); > > > } > > > > function getSentMessages($format, $since = NULL, $since_id = > > > 0, $page = 1) { > > > $api_call = > > > sprintf("http://twitter.com/direct_messages/sent.%s", $format); > > > if ($since != NULL) { > > > $api_call .= sprintf("?since=%s", > > > urlencode($since)); } > > > if ($since_id > 0) { > > > $api_call .= sprintf("%ssince_id=%d", > > > (strpos($api_call, "?since") === false) ? "?" : "&", $since_id); > > > } > > > if ($page > 1) { > > > $api_call .= sprintf("%spage=%d", > > > (strpos($api_call, "?since") === false) ? "?" : "&", $page); > > > } > > > return $this->APICall($api_call, true); > > > } > > > > function newMessage($format, $user, $text) { > > > $text = urlencode(stripslashes(urldecode($text))); > > > $api_call = > > > sprintf("http://twitter.com/direct_messages/new.%s?user= > > > %s&text=%s", $format, $user, $text); return > > > $this->APICall($api_call, true, true); } > > > > function destroyMessage($format, $id) { > > > $api_call = > > > sprintf("http://twitter.com/direct_messages/destroy/%s. > > ... > > read more »
