Jahova
18-10-2009, 06:26 PM
I've been using the following PHP code (not made by me) to display my latest twitter tweets on my site. I got two questions for you guys about the code today;
Is there a better and easier way to code the same thing, still in PHP
If twitter is offline, the script will stop the rest of my page from loading. Is there a way to make the rest of my page continue loading if twitter is offline, and show a message to say twitter is offline.
<?php
function getTweet($url) {
$feed = file_get_contents($url);
$xml = new SimpleXMLElement($feed);
$tweet = $xml->entry->title;
return $tweet;
}
$username = "TomSpit";
$url = "http://search.twitter.com/search.atom?q=from:".$username."&rpp=1";
echo "<a href=\"http://twitter.com/tomspit/\" onclick=\"window.open(this); return false;\">";
echo getTweet($url);
echo "</a>";
?>
All help receives a +REP. Tom.
Is there a better and easier way to code the same thing, still in PHP
If twitter is offline, the script will stop the rest of my page from loading. Is there a way to make the rest of my page continue loading if twitter is offline, and show a message to say twitter is offline.
<?php
function getTweet($url) {
$feed = file_get_contents($url);
$xml = new SimpleXMLElement($feed);
$tweet = $xml->entry->title;
return $tweet;
}
$username = "TomSpit";
$url = "http://search.twitter.com/search.atom?q=from:".$username."&rpp=1";
echo "<a href=\"http://twitter.com/tomspit/\" onclick=\"window.open(this); return false;\">";
echo getTweet($url);
echo "</a>";
?>
All help receives a +REP. Tom.