Error: Could not fetch http://thedevnet.com/wp-content/plugins/gd-star-rating/css/gdsr.css.php?t=0&s=a10i10m20k20c05r05%23121620243046%23121620243240%23s1pchristmas%23s1pcrystal%23s1pdarkness%23s1poxygen%23s1goxygen_gif%23s1pplain%23s1ppumpkin%23s1psoft%23s1pstarrating%23s1pstarscape%23t1pclassical%23t1pstarrating%23t1gstarrating_gif&ver=1.7.2 for caching. You might need to exclude this file in WP Minify options. The Developer Network – Twitter Class

Twitter Class

Twitter is the latest rage in social networking and micro-blogging services.

A user’s updates are displayed on their profile page and are delivered to other users who have signed up to receive them.

Updates to the tweeter page can be made with the interface on the website, gateway SMS, or a third party application like browser plugins, online services, widets, etc.

Millions of users and companies are already using Twitter to communicate or exchange information. Website owners, users, and developers feel a growing need to update and display their tweets withgout the hassle of dealing with additional software or with the twitter website.

This is a comprehensive sample implementation of twitter services in PHP. The result is a standardized PHP class that can be downloaded below.

In order to use this PHP-class, your server needs to run PHP at least in version 5.2 including the cURL-library.

Please bear in mind that all in- and outputs are handled in UTF-8. This may cause problems if you use this class in combination with applications that feature another encoding. You will have to encode or decode data in these cases.

The first step to use the Twitter class in your PHP-application is to include the classfile itself (dependant on your installation, you probably will have to adjust the contained filepath):

Step 1 (include and create the object):

  1. <?
  2.  // Twitter via PHP
  3.  // http://thedevnet.com/php/classes/twitter-class/
  4.  require_once('twitter.php');
  5.  $Twitter = Twitter::getInstance();
  6.  $Twitter->setUser('yourUsername','yourPassword');
  7. ?>

Functionality

Now you are ready to post your first tweet! You do this using post()

Using Post() for your first tweet:

  1. <?
  2.  $Twitter->post('This is a new tweet!');
  3. ?>

This method expects a string parameter (which is limited to 140 characters) and will post it to Twitter.
It returns true in case of a successful posting or a string formatted message in case of occuring errors.

Get information regarding a post[returns array with all available postdata or a string with error message]:

  1. <?
  2.  $Twitter->getPost(idOfDesignatedTweet);
  3. ?>

Delete Post[returns boolean or string with error message]:

  1. <?
  2.  $Twitter->deletePost(idOfDesignatedTweet);
  3. ?>

Get Detailed information on a user[returns string]:

  1. <?
  2.  $Twitter->getUser('designatedUsername');
  3. ?>

You can even get userlists:

  1. <?
  2.  $Twitter->getFriends();
  3.  $Twitter->getFollowers();
  4.  $Twitter->getFeaturedUsers();
  5. ?>

Another important figure when working with Twitter are timelines.

use the following 4 methods for retrieving them:

  1. <?
  2.  $Twitter->getMentions(optionalIntegerAmountOfRequiredItems);
  3.  $Twitter->getUserTimeline(optionalIntegerAmountOfRequiredItems);
  4.  $Twitter->getFriendsTimeline(optionalIntegerAmountOfRequiredItems);
  5.  $Twitter->getPublicTimeline();
  6. ?>
PHP Twitter API Class
phptwitterclass_v1_7_1.zip
Version: 1.7.1

34.1 KiB
38 Downloads
Details…

GD Star Rating
loading...

Originally posted 2009-10-21 05:17:46.

Popularity: 9%

Posted by natster   @   10 August 2010

Like this post? Share it!

RSS Digg Twitter StumbleUpon Delicious Technorati Facebook

0 Comments

No comments yet. Be the first to leave a comment !
Leave a Comment

You must be logged in to post a comment.

Previous Post
« Speed Limit Download of File
Next Post
Get Google Page Rank of a Site »
Powered by Wordpress   |   Lunated designed by ZenVerse