Voice Twitter – Access your tweets over phone – Part I January 21, 2009
Do you Twitter? Would’t it be convenient to hear and reply back to tweets using your phone? Here is the code that makes it all possible.
In this code sample, we show you an easy way to retrieve twitter feeds and play them using VoicePHP. This code example also shows how to use JSON (JavaScript Object Notation) within VoicePHP.
<?php
// The twitter feed you are interested in
$tweetname = 'CNN';
$tweeturl = 'http://twitter.com/statuses/user_timeline/cnn.json';
echo " Welcome To The Voice PHP Tweet Reader ";
$response = Fetch($tweeturl); //Get all the tweets
if (empty($response)) {
echo 'No Tweets';
return;
}
echo "Reading $tweetname Tweets";
$json_res = json_decode ($response, true);
$i = 0;
$number_msg = count($json_res);
while($i < $number_msg){
$text = $json_res[$i]['text'];
//Eat any URL we encounter in the tweet
$result = preg_replace("^((http://)([a-zA-Z0-9?&%.;:/=+_-]*))^",'', $text);
$i++;
speak("Reading Tweet $i ",0);
speak($result,1);
sleep(2);
}
echo "Thank you for trying Voice PHP Tweet Reader";
?>
In part 2 of this, we will also show how easy it is to Tweet back using voice.
Try It Now!
Click the button below or call +15672449921 to run the application.
Does'nt it look easy? Try VoicePHP for yourself and feel free to modify the above script. VoicePHP is easy and accessible from your free TringMe account. More details at http://voicephp.com/howitworks.html
Leave a Comment
If you would like to make a comment, please fill out the form below.





