
foucquet
Members-
Posts
48 -
Joined
-
Last visited
Everything posted by foucquet
-
Thanks, that's so obvious now that I see it. I was busy playing around with str functions and getting nowhere...
-
I am parsing an rss feed from my flickr photostream using this:- <?php $url = "http://api.flickr.com/services/feeds/photos_public.gne?id=49466419@N05&lang=en-us&format=rss_200"; $rss = simplexml_load_file($url); if($rss) { echo '<h1>'.$rss->channel->title.'</h1>'; echo '<li>'.$rss->channel->pubDate.'</li>'; $items = $rss->channel->item; foreach($items as $item) { $title = $item->title; $link = $item->link; $published_on = $item->pubDate; $description = $item->description; echo '<h3><a href="'.$link.'">'.$title.'</a></h3>'; echo '<span>('.$published_on.')</span>'; echo '<p>'.$description.'</p>'; } } ?> which gives me this as the description for each image:- public 'description' => string ' <p><a href="http://www.flickr.com/people/alfthomas/">Alf Thomas</a> posted a photo:</p> <p><a href="http://www.flickr.com/photos/alfthomas/14064465890/" title="harlaw_12"> <img src="http://farm6.staticflickr.com/5077/14064465890_83c02ecec6_m.jpg" width="240" height="110" alt="harlaw_12" /> </a> </p> <p>A view of Harlaw Reservoir.</p>' (length=338) What I actually want is the photo (linked back) without the "Alf Thomas posted a photo" bit, does anyone have any idea how I would go about cloning that bit out?
-
Of course! What a dummy, Iknew a fresh pair of eyes would help - thanks.
-
I am trying to put an rss feed from my Flickr account into my website I have got thus far with my class:- <?php // Flickr Class class flickr { // Properties var $feed; //=================== // Construct Flickr function __construct($feed) { $this->feed = $feed; } //=================== // Parse Method function parse() { $rss = simplexml_load_file($this->feed); $photodisp = array(); foreach ($rss->channel->item as $item) { $link = (string) $item->link; // Link to this photo $title = (string) $item->title; // Title of this photo $media = $item->children('http://search.yahoo.com/mrss/'); $thumb = $media->thumbnail->attributes(); $url = (string) $thumb['url']; // URL of the thumbnail $width = (string) $thumb['width']; // Width of the thumbnail $height = (string) $thumb['height']; // Height of the thumbnail $photodisp[] = <<<________________EOD {$title} ________________EOD; } return $photodisp; } //=================== // Display Method function display($numrows=6,$head="Photos on Flickr") { $photodisp = $this->parse(); $i = 0; $thumbs = <<<____________EOD $head ____________EOD; while ( $i < $numrows ) { $thumbs .= $photodisp[$i]; $i++; } $trim = str_replace('http://api.flickr.com/services/feeds/photos_public.gne?id=', '',$this->feed); $user = str_replace('〈=en-us&format=rss_200','',$trim); $thumbs .= <<<____________EOD View All Photos on Flickr ____________EOD; return $thumbs; } //=================== } //End of Class ?> // <- Line 66 and it gives me "Parse error: syntax error, unexpected end of file in C:\wamp\www\image-a-nation\test4_class.php on line 66". I thought it might be an unclosed brace/bracket or something like that, but no amount of checking finds anything - would appreciate a fresh pair of eyes...
-
Hmm, didn't spot that one - definitely an autopilot typo... Thanks
-
I am trying to iterate through an array of images and am having trouble with next/prev links. I thought that this should basically work as a starting point:- $images = array(); $img_loc = 'images/'; if ($handle = opendir($img_loc)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $images[] = $file; } } closedir($handle); } //>>> ==================================================================================== //>>> Block of code for Next/Prev links on images if (isset($_REQUEST['id'])) { $id = $_REQUEST['id']; } else { $id = 0; // Whatever the default starting value should be } $self = $_SERVER['PHP_SELF'] . "?$id="; $first = 0; // Because arrays are numbered from 0 $last = 7; $pic = $img_loc . $images[$id]; echo "<p><img src=\"$pic\"></p>"; if ($id < $last) { echo "<a href=".$self.($id + 1)."><h3>Next</h3></a>"; } if ($id > $first) { echo "<a href=".$self.($id - 1)."><h3>Previous</h3></a>"; } //=====================================================================================<<< //>>> ==================================================================================== //>>> Checking on what the variables are doing var_dump ($images); echo "File location = " . $pic . "<br>"; echo "First = " . $first . "<br>"; echo "Last = " . $last . "<br>"; echo "File id = " . $id . "<br>"; echo "Self = " . $self . "<br>"; echo "Server = " . $_SERVER['PHP_SELF'] . "<br>"; //=====================================================================================<<< and to an extent it does giving me:- IMAGE Next array (size = 8 ) 0 => string 'decisions.jpg' (length=13) 1 => string 'dual_concentration.jpg' (length=22) 2 => string 'generation_gap.jpg' (length=18) 3 => string 'just_looking.jpg' (length=16) 4 => string 'mid_stride.jpg' (length=14) 5 => string 'no7.jpg' (length=7) 6 => string 'plugged.jpg' (length=11) 7 => string 'runner.jpg' (length=10) File location = images/decisions.jpg First = 0 Last = 7 File id = 0 Self = /imageanation/next_prev_link_test.php?0= Server = /imageanation/next_prev_link_test.php However when I click next it changes the url from localhost/imageanation/next_prev_link_test.php to localhost/imageanation/next_prev_link_test.php?0=1 and reloads the same image. Hours of head scratching has not provided me with any solution, which I am sure will be quite simple if I could only see it.
-
OK, OK, I'm a complete dummy - didn't even spot those errors, too busy looking for everything but the bleedin' obvious! That indeed now works (hides head in shame!)
-
I am trying to bring a flickr feed into a webpage, and can't work out why this:- <?php // >>> Set up the variables needed <<< $photos = array(); $encode_params = array(); $maximgs = 19; // >>> This need to be 1 less than actual req'd No. as array counts from 0 <<< // >>> Set up the parameters for the API <<< $api_params = array( 'api_key' => 'my api key', 'method' => 'flickr.photos.search', 'user_id' => 'my id', 'format' => 'php_serial', ); //>>> Encode the parameters ready to make API request <<< foreach($api_params as $k => $v){ $encode_params[] = urlencode($k) . '=' . urlencode($v); } var_dump($encode_params); // >>> Construct API url and make the request <<< $api_url = 'http://api.flickr.com/services/rest/?' . implode('&', $encode_params); var_dump($api_url); // >>> Retrieve images <<< $rsp = file_get_contents($api_url); $rsp_obj = unserialize($rsp); echo $rsp_obj; var-dump($rsp_obj['photos']['photo']); //>>> Line 37 <<< ?> gives me "Parse error: syntax error, unexpected T_VAR in C:\wamp\www\php\flickr tests\prev3~.php on line 37".