Ryan Fitton
09-13-2010, 03:38 PM
Hi, I have some code below:
<?php
// What do you want to search for?.
$search = "bb11";
// Prefix - some text you want displayed before your latest tweet.
// (HTML is OK, but be sure to escape quotes with backslashes: for example href=\"link.html\")
$prefix = "";
// Suffix - some text you want display after your latest tweet. (Same rules as the prefix.)
$suffix = "";
$feed = "http://search.twitter.com/search.atom?q=" . $search . "&rpp=1";
function parse_feed($feed) {
$stepOne = explode("<content type=\"html\">", $feed);
$stepTwo = explode("</content>", $stepOne[1]);
$tweet = $stepTwo[0];
$tweet = str_replace("<", "<", $tweet);
$tweet = str_replace(">", ">", $tweet);
$tweet = str_replace("&", "&", $tweet);
return $tweet;
}
$twitterFeed = file_get_contents($feed);
$final_tweet = stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);
echo $final_tweet
?>
<?php
require_once('flickr.php');
$Flickr = new Flickr;
$data = $Flickr->search('Seach Terem Here');
foreach($data['photos']['photo'] as $photo) {
// the image URL becomes somthing like
// http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}.jpg
echo '<img src="http://farm' . $photo["farm"] . '.static.flickr.com/' . $photo["server"] . '/' . $photo["id"] . '_' . $photo["secret"] . '.jpg">';
}
?>
in the flickr section where it says:
$data = $Flickr->search('Seach Terem Here');
I am wanting to put a variable in, so that it searches using the words in the tweet from
$final_tweet
So the flickr code line would be like this:
$data = $Flickr->search($final_tweet);
But if i put it in like this, it loads the tweet but not any images:
$data = $Flickr->search($final_tweet);
you can view it online here: http://ryanfitton.co.uk/search/
<?php
// What do you want to search for?.
$search = "bb11";
// Prefix - some text you want displayed before your latest tweet.
// (HTML is OK, but be sure to escape quotes with backslashes: for example href=\"link.html\")
$prefix = "";
// Suffix - some text you want display after your latest tweet. (Same rules as the prefix.)
$suffix = "";
$feed = "http://search.twitter.com/search.atom?q=" . $search . "&rpp=1";
function parse_feed($feed) {
$stepOne = explode("<content type=\"html\">", $feed);
$stepTwo = explode("</content>", $stepOne[1]);
$tweet = $stepTwo[0];
$tweet = str_replace("<", "<", $tweet);
$tweet = str_replace(">", ">", $tweet);
$tweet = str_replace("&", "&", $tweet);
return $tweet;
}
$twitterFeed = file_get_contents($feed);
$final_tweet = stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);
echo $final_tweet
?>
<?php
require_once('flickr.php');
$Flickr = new Flickr;
$data = $Flickr->search('Seach Terem Here');
foreach($data['photos']['photo'] as $photo) {
// the image URL becomes somthing like
// http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}.jpg
echo '<img src="http://farm' . $photo["farm"] . '.static.flickr.com/' . $photo["server"] . '/' . $photo["id"] . '_' . $photo["secret"] . '.jpg">';
}
?>
in the flickr section where it says:
$data = $Flickr->search('Seach Terem Here');
I am wanting to put a variable in, so that it searches using the words in the tweet from
$final_tweet
So the flickr code line would be like this:
$data = $Flickr->search($final_tweet);
But if i put it in like this, it loads the tweet but not any images:
$data = $Flickr->search($final_tweet);
you can view it online here: http://ryanfitton.co.uk/search/