Third Party Software
From Plings Info
Contents |
Using phpFlickr Class 2.1.0 written by Dan Coulter to get Venue Images
The key to getting images is the use of machine tags...
Venue images stored at Flickr can be searched for via the "plings:place=" machine tag, for example, using the flickr API to search for the venue 1805 (http://places.plings.net/index.php/v/1805) you would use the machine tag "plings:place=1805"
The documentation relies on the use of an external library phpFlickr Class 2.1.0 written by Dan Coulter which can be found at: http://www.phpflickr.com/
Initialising the class:
<?php define('PHPFLICKRROOT', "{$_SERVER['DOCUMENT_ROOT']}/include/phpFlicker"); require(PHPFLICKRROOT.'/phpFlickr.php'); $flickrAPI = new phpFlickr("YOUR API KEY"); ?>
Getting the images for a venue (or all venues)
<?php //Don't forget to include the class! $flickrImages = $flickrAPI->photos_search(array( //e.g. replace YOUR VENUE ID NUMBER HERE with 41997 for Walthamstow Library //NOTE: using 'plings:place=' will return all photos with a plings place machine tag 'machine_tags' => 'plings:place=YOUR VENUE ID NUMBER HERE', 'content_type' => 1 )); if ($flickrImages['total'] > 0) { while( is_array( ($thisImage=array_shift($flickrImages['photo'])) ) ) { ?> <a href="http://flickr.com/photos/<?=$thisImage['owner']?>/<?=$thisImage['id']?>" target="_new"> <img src="http://farm<?=$thisImage['farm']?>.static.flickr.com/<?=$thisImage['server']?>/<?=$thisImage['id']?>_<?=$thisImage['secret']?>_t.jpg" title="<?=$thisImage['title']?>" border="0"/> </a> <?php } // EO While ?> <br clear="left" /> <?php } else { ?> <em>There are no images associated with this Place.</em><br /> <?php } ?>
Pulling the Venue ID from the machine tag
<?php //Don't forget to include the class! $flickrImages = $flickrAPI->photos_search(array( //Sets up the search parameters to be used by the Flickr API, //Specifying no value for the plings:place machine tag, returns them all 'machine_tags' => 'plings:place=', 'content_type' => 1 )); //Make the call to Flickr and see if we have any results if ($flickrImages['total'] > 0) { while( is_array( ($thisImage=array_shift($flickrImages['photo'])) ) ) { //This routine pulls out the VenueID from the machine tag and stores it in $venueID $thisImage['tags'] = $flickrAPI->tags_getListPhoto($thisImage['id']); // Loop through tags to find the places machine tag foreach($thisImage['tags'] as $thisTag) { if ($thisTag['machine_tag']) { if (eregi('^plings:place=([0-9]+)$', $thisTag['raw'], $mat)) { $venueID = $mat[1]; } } } echo $venueID ?> <a href="http://flickr.com/photos/<?=$thisImage['owner']?>/<?=$thisImage['id']?>" target="_new"> <img src="http://farm<?=$thisImage['farm']?>.static.flickr.com/<?=$thisImage['server']?>/<?=$thisImage['id']?>_<?=$thisImage['secret']?>_t.jpg" title="<?=$thisImage['title']?>" border="0" /> </a> <?php } // EO While ?> <br clear="left" /> <?php } else { ?> <em>There are no images associated with this Place.</em><br /> <?php } ?>
Parsers
clsParseXML
We've had success using clsParseXML for parsing XML. (Particularly useful for those of still working with PHP4 - also works with PHP5)
XML Parser Class by Eric Rosebrock http://www.phpfreaks.com
Class originated from: kris@h3x.com AT: http://www.devdump.com/phpxml.php
Usage:
<?php include 'clsParseXML.php'; $xmlparse = &new ParseXML; $xml = $xmlparse->GetXMLTree('/path/to/xmlfile.xml'); //The path to the XML file may be a local file or a URL. //Returns the elements of the XML file into an array with it's subelements as keys and subarrays. echo "<pre>"; print_r($xml); echo "</pre>"; ?>
MagpieRSS
We use this at stockport.plings.net, to parse RSS and it does the job well: http://magpierss.sourceforge.net/
SimplePie
For RSS feeds SimplePie is great: http://simplepie.org/

