PHP Classes

File: demo.php

Recommend this page to a friend!
  Classes of Muhammed Mamedov  >  Twitter Updater  >  demo.php  >  Download  
File: demo.php
Role: Example script
Content type: text/plain
Description: Demo with all functions for TwitterUpdater
Class: Twitter Updater
Update and retrieve the statuses of a Twitter user
Author: By
Last change:
Date: 6 years ago
Size: 1,648 bytes


Class file image Download
 * Simple Twitter Status Update - 3 lines of code!
$twitter = new TwitterUpdater("myusername","mypassword");
$twitter->updateStatus('I am a tweeeter!! This my API tweet!');
//uncomment this line to see response from Twitter
//echo twitter->getReponse();

 * Another Twitter Status Update, but with a long URL
 * If you need tweet a long URL with your tweet post,
 * parse your long URL with built-in to get a short URL,
 * don't waste your precious tweet characters:)
 * Get a free API key:
$twitter->setupBitly("BITLY_USERNAME", "BITLY_API_KEY");
$myurl = $twitter->bitlyURL('');
//myurl is now shortened to something like:
$twitter->updateStatus($myurl. '- Check this nice song. Artist: Ma-Ro, title: Sana bagly. This is a long tweeet!');

 * Retrieve Your Tweets
// Get most recent 20 tweets (Tweeter default)
$statuses = $twitter->getUserTimeline();
//statuses is array [text, created_at, source, id]
echo $statuses[0][0];
//Get any number of tweets, just pass it as a parameter
$statuses = $twitter->getUserTimeline($count=5);

 * Delete a tweet

//Pass tweet id. IDs are returned with getUserTimeline() call

 * Update status of your other Tweeter account

$twitter->updateStatus('Now I am tweeting on my other Account! How cool is that?');