Created
February 3, 2010 15:36
-
-
Save fleeting/293688 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//The following code was submitted by Tycho Lyben for inclusion in WP-TwitterSearch. Has not been tested yet. | |
$path = CACHE_PATH."/".md5("'phrase'=>$phrase,'from'=>$from,'rpp'=>$rpp,'lang'=>$lang,'nots'=>$nots"); | |
if (file_exists($path) && filectime($path)>time()-1800) { // cache for 30 min | |
$x = unserialize(file_get_contents($path)); | |
echo $x; | |
exit; | |
} | |
// Search Twitter API Request | |
$response = $twitter->searchAPI('ATOM'); | |
$feed = $response->search($q,array('phrase'=>$phrase,'from'=>$from,'rpp'=>$rpp,'lang'=>$lang,'nots'=>$nots)); | |
if (!file_exists($path)) @mkdir($path); | |
if (file_exists($path) && !@trim($feed->getData())) { | |
$x = unserialize(file_get_contents($path)); | |
echo $x; | |
} else if (!@trim($feed->getData())) { | |
echo $feed; | |
} else { | |
file_put_contents($path, serialize($feed)); | |
echo $feed; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment