<?xml version="1.0" encoding="utf8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>daisyrust.com &#187; web 2.0</title>
	<atom:link href="http://www.daisyrust.com/category/web-20/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.daisyrust.com</link>
	<description>digital art hacks - quartz composer - creative code - exhibition</description>
	<pubDate>Mon, 18 Aug 2008 12:30:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
	<language>en</language>
			<item>
		<title>Using Magpie RSS to scrape blog headlines to html</title>
		<link>http://www.daisyrust.com/2006/03/25/using-magpie-rss-to-scrape-blog-headlines-to-html/</link>
		<comments>http://www.daisyrust.com/2006/03/25/using-magpie-rss-to-scrape-blog-headlines-to-html/#comments</comments>
		<pubDate>Sat, 25 Mar 2006 09:43:42 +0000</pubDate>
		<dc:creator>ian grant</dc:creator>
		
		<category><![CDATA[digital art hacks]]></category>

		<category><![CDATA[general]]></category>

		<category><![CDATA[net art]]></category>

		<category><![CDATA[web 2.0]]></category>

		<guid isPermaLink="false">http://www.daisyrust.com/2006/03/25/using-magpie-rss-to-scrape-blog-headlines-to-html/</guid>
		<description><![CDATA[Creating a mashup often requires manipulating RSS feeds and exploring XML formats. MagpieRSS is an excellent tool that can simplify manipulations with RSS feeds. This article illustrates a simple, introductory use of this powerful tool.]]></description>
			<content:encoded><![CDATA[<p>This walkthrough assumes you have access to a server running PHP and the ability to change permissions on directories.</p>
<p>Step One: <a href="http://magpierss.sourceforge.net/">Get MagpieRSS here!</a> Head to sourceforge and grab the latest copy of the excellent MagpieRSS.</p>
<p>Step Two: Read the docs. Quickstart: setup a directory on the webserver that looks a bit like this:</p>
<p><img src="http://www.daisyrust.com/wp-content/images/directory_001.png" border="1" alt="Directory 001" hspace="4" vspace="4" width="355" height="192" /></p>
<p>Set the permission of the &#8220;cache&#8221; directory to 777 - world writable. You may be able to get away with more restricted permissions.</p>
<p>Step Three: use the code below as a starting point for exploration. You can see the results of it here<a href="http://www.daisyrust.com/magpie/magpierss_test_001.php"> here </a></p>
<p>There are several lines you can comment/uncomment to see the object magpierss returns. The current example is set to return the results of a blogger feed. With some extra code one can detect the feed and provide summaries accordingly&#8230; that is to come.</p>
<pre name="code" class="php">

&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;

&lt;?php
require_once(&#039;magpierss/rss_fetch.inc&#039;);
// the @ suppresses errors
// change the URL to the blog atom / rss feed.
// If the feed is not atom but RSS some of the
// item names will be different - one will need
// to check. The info is in the &#039;channel&#039; array.

$rss = @fetch_rss( &#039;http://internetandnetworkart.blogspot.com/atom.xml&#039; );
// $rss = @fetch_rss( &#039;http://ellington.tvu.ac.uk/dev/?feed=rss2&#039; );

// dump the object to the screen to study the structure magpie returns
echo &#039;

&#039;;
print_r($rss);
echo &#039;

&#039;;
// end dump

$channel = $rss-&gt;channel;
echo &quot;Blog Title: &quot; .$channel[&#039;title&#039;];

//display links recent blog entries:

echo â€œLatest blog additions:\n&quot;;
foreach ($rss-&gt;items as $item) {

   $href = $item[&#039;link&#039;];
   $title = $item[&#039;title&#039;];
   $author = $item[&#039;author_name&#039;];
   $created = $item[&#039;created&#039;];
   $content = $item[&#039;atom_content&#039;];

   echo &quot;$title created by $author on $created\n
   $content\n&quot;
}

echo &#039;

&#039;;

?&gt;
</pre>
<p>The sample files can be downloaded here:</p>
<p><a href="http://www.daisyrust.com/magpie/magpierss_blog_scrape.zip">magpierss_blog_scrape.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.daisyrust.com/2006/03/25/using-magpie-rss-to-scrape-blog-headlines-to-html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Basic Telematics using SMS and the Web</title>
		<link>http://www.daisyrust.com/2006/03/24/basic-telematics-using-sms-and-the-web/</link>
		<comments>http://www.daisyrust.com/2006/03/24/basic-telematics-using-sms-and-the-web/#comments</comments>
		<pubDate>Fri, 24 Mar 2006 22:00:29 +0000</pubDate>
		<dc:creator>ian grant</dc:creator>
		
		<category><![CDATA[digital art hacks]]></category>

		<category><![CDATA[flickr]]></category>

		<category><![CDATA[telematics]]></category>

		<category><![CDATA[web 2.0]]></category>

		<guid isPermaLink="false">http://www.daisyrust.com/2006/03/24/basic-telematics-using-sms-and-the-web/</guid>
		<description><![CDATA["Flickr Peep Show" connected mobile phone networks and a popular internet social photography network by means of SMS messaging and explored public display and projection. See <a href="http://www.mediamatic.net/artefact-200.9203.html">Flickr Peep Show</a> for more information. If you wish to do this style of creative telematic work, read on!

There are a number of ways to get going with SMS (Short Message Service) and web page integration. Some techniques are trickier and more expensive than others. The technique here uses a Bluetooth-Enabled Mobile Phone, A Bluetooth-Enabled Mac/Linux Server and a free server tool called <a href="http://kinks.ultralab.ac.uk/ultrasms/">UltraSMS</a>]]></description>
			<content:encoded><![CDATA[<p><strong>Integrating Short Message Service (SMS) and the Web</strong></p>
<p><strong>Introduction</strong></p>
<p>&#8220;Flickr Peep Show&#8221; connected mobile phone networks and a popular internet social photography network by means of SMS messaging and explored public display and projection. See <a href="http://www.mediamatic.net/artefact-200.9203.html">Flickr Peep Show</a> for more information. If you wish to do this style of creative telematic work, read on!</p>
<p>There are a number of ways to get going with SMS (Short Message Service) and web page integration. Some techniques are trickier and more expensive than others. Some rely on you having direct access and control over the web server - this may be possible when you are using web technologies to do installation / gallery work and are providing the infrastructure yourself (eg. degree shows).</p>
<p>The three options I write about here are:</p>
<p><strong>(Option 1)</strong> Subscribe to an online SMS gateway<br />
<strong>(Option 2)</strong> Use a GSM Modem<br />
<strong>(Option 3)</strong> Using a Bluetooth-Enabled Mobile Phone, A Bluetooth-Enabled Mac/Linux Server and <a href="http://kinks.ultralab.ac.uk/ultrasms/">UltraSMS</a></p>
<hr /><strong>(Option 1) Subscribe to an online SMS gateway for sending and receiving messages.</strong></p>
<p>This option is the only one that does not require physical access to the web server.</p>
<p><strong>(a) Find a service and sign up. </strong><br />
I use tm4b - bulk sms gateway. <a href="http://www.tm4b.com/">http://www.tm4b.com/</a></p>
<p>Signing up is free [true circa March 2005). You have many options for sending messages, via their web interface, via their simple Application Programming Interface (API) using scripting languages like php. The cost per message is slightly cheaper than mobile network operators charge.</p>
<p><strong>(b) Sending a message using tm4b's SMS API and PHP</strong><br />
Here is a working php script. Download here (ctrl/right click): <a href="http://www.daisyrust.com/wp-content/code/sms.php.txt">sms.php.txt</a>.</p>
<pre name="code" class="php">
&lt;?php
//initialize the request variable
$request = &quot;&quot;;
//this is the username of our TM4B account
$param[&quot;username&quot;] = &quot;[your TM4B username]&quot;;
//this is the password of our TM4B account
$param[&quot;password&quot;] = &quot;[your TM4B password]&quot;;
//this is the message that we want to send
$param[&quot;msg&quot;] = &quot;This is a sample SMS.&quot;;
//these are the recipients of the message
$param[&quot;to&quot;] =
&quot;[recipients phone # or multiple #s seperated by a pipe (|)]&quot;;
//this is our sender
$param[&quot;from&quot;] = &quot;Ian&quot;;
//we want to send the message via first class
$param[&quot;route&quot;] = &quot;frst&quot;;
//we are only simulating a broadcast
//$param[&quot;sim&quot;] = &quot;yes&quot;;
// un-comment this line to enter &#039;simulation&#039; mode.
// It will test the script without sending a message (saving money)

//traverse through each member of the param array building
//the url query
foreach($param as $key=&gt;$val){
//we have to urlencode the values
$request.= $key.&quot;=&quot;.urlencode($val);
//append the ampersand (&amp;) sign after each
//parameter/value pair
$request.= &quot;&amp;amp;&quot;;
}
//remove the final ampersand sign from the request
$request = substr($request, 0, strlen($request)-1);
//echo $request;
//uncomment this line to view the URL that is constructed
//using the code above.
//this is the url of the gateway&#039;s interface
// method 1 -- using CURL - this must be installed
$url = &quot;http://www.tm4b.com/client/api/send.php&quot;;
//above: the url of the gateway&#039;s interface
$query = $url.&quot;?&quot;.$request;
$ch = curl_init($query); //initialize curl handle
//run the whole process and return the response
$response = curl_exec($ch);
&lt;pre&gt;&lt;code&gt;curl_close($ch);//close the curl handle
// uncomment to show the result onscreen for debugging
//echo $response;
</pre>
<p><strong></strong></p>
<p><strong>(c) Receiving messages</strong></p>
<p>Receiving messages via a web page and handling that message within a script is slightly more involved. Some web based &#8216;bulk sms&#8217; suppliers charge a packet (no network pun intended) for this facility - you normally need a dedicated number or short number and the set up costs are prohibitive - with monthly fees sometimes as high as Â£1000! I am have a &#8216;keyword&#8217; and a dedicated short number from tm4b.com. I&#8217;ll update this post / or post another entry when I have had a chance to evaluate this service properly. The API is flexible and well documented.</p>
<p>[update 18 July 2006 - I won a dedicated keyword on a long-number-service of my choice in a customer service survey for tm4b - I can highly recommend them as a web based SMS service - check out their current options here: <a href="http://www.tm4b.com/">http://www.tm4b.com/</a></p>
<p>The principle is: through your suppliers web interface you set up a "message receiver" and a "message responder". tm4b.com has 3 main channels for handling received messages: depicted here (read from bottom to top):</p>
<p><img title="Tm4B.com Receiving Model" src="http://www.daisyrust.com/wp-content/images/tm4b_model.png" border="1" alt="Tm4B Receiving Model Image" hspace="4" vspace="4" width="270" height="227" /></p>
<p>In the case of our artistic endeavors, the communication model may not immediately re-route the message to a user. It is likely the text message will be intercepted by a web script using the SMS API and processed in a creative and interesting way. For example: text process the message, stripping keywords and then flickr retrieving images, or store the message in a mysql database and processed later - maybe into a fragmented hypertext narrative.</p>
<p><strong>(Option 2) GSM Modem with SMS capabilities with Built in SIM Card Reader</strong></p>
<p>You need to buy a modem and have a spare SIM card with a phone number, dedicated only to receiving SMS and have physical access to a server.</p>
<p>Richard Colson (Digital Arts Pathway Leader) has a Falcom GSM modem for use in Digital Art modules. [Note: this post was originally written as a tutorial for students on the BA (Hons) in Digital Art at TVU, London. <a href="http://mercury.tvu.ac.uk/da/">http://mercury.tvu.ac.uk/da/</a>] The drivers are windows only and as yet, I have not tested it. It can send/receive SMS message to a dedicate phone number and relays the message to the PC it is connected to. Using cross platform open source SMS tools (<a href="http://smstools.meinemullemaus.de/">http://smstools.meinemullemaus.de/</a>), you can configure a server box to do near enough what you wish. Using it, Richard has created a shockwave movie that interfaces with a matrix display and outputs SMS content.</p>
<p><strong>(Option 3) Instant SMS to MySQL Using a Bluetooth-Enabled Mobile Phone, A Bluetooth-Enabled Mac/Linux Server and an Open Source &#8216;Daemon&#8217; Called UltraSMS</strong></p>
<p><strong>Requires:</strong> Physical access to a bluetooth enabled linux or Mac OS X Server, running MySQL and a supported phone</p>
<p>This option is very cool and relatively straight forward. Put simply: the server and the phone are &#8216;paired&#8217; via bluetooth. A small piece of software (ultraSMS), called a daemon, runs continuously in the background and &#8216;listens&#8217; for an incoming SMS. As soon as a SMS is received, the daemon pulls the SMS data off the phone, inserts it into a MySQL database and tidies up by deleting the received message from the phone. As soon as the SMS is in the database, any server side scripting language can access, process and output the data.</p>
<p><strong>Step by step</strong></p>
<p><strong>(a)</strong> Download UltraSMS here: <a href="http://kinks.ultralab.ac.uk/ultrasms/">http://kinks.ultralab.ac.uk/ultrasms/</a><br />
UltraSMS is an open source daemon for sending and recieving SMS messages. It will work on Mac OS X and Linux systems. It comes with full instructions for use.</p>
<p><strong>(b)</strong> Use phpMyAdmin, or similar tool, to create a MySQL database on the webserver to contain the SMS Data - the SQL file (ultrasms.sql) to do this for you is included in the ultraSMS distribution.</p>
<p><a onclick="window.open('http://www.daisyrust.com/wp-content/images/01_create_db-1.png','popup','width=1074+20,height=972+20,scrollbars=no,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=yes,left=0,top=0');return false" href="http://www.daisyrust.com/wp-content/images/01_create_db-1.png"><img src="http://www.daisyrust.com/wp-content/images/01_create_db-1-tm.jpg" border="1" alt="01 Create Db-1" hspace="4" vspace="4" width="110" height="100" /></a></p>
<p><strong>(c)</strong> &#8216;Pair&#8217; the server via Bluetooth with a supported phone (luckily mine was on the short list!).</p>
<p>On a mac you do from the bluetooth preferences, detailed instructions are in the documentation of ultraSMS (click for larger images):</p>
<p><a onclick="window.open('http://www.daisyrust.com/wp-content/images/bluetooth_01.png','popup','width=595+20,height=636+20,scrollbars=no,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=yes,left=0,top=0');return false" href="http://www.daisyrust.com/wp-content/images/bluetooth_01.png"><img src="http://www.daisyrust.com/wp-content/images/bluetooth_01-tm.jpg" border="1" alt="Bluetooth 01" hspace="4" vspace="4" width="93" height="100" /></a></p>
<p>Pair the phone, then click the button to edit the serial ports:</p>
<p><a onclick="window.open('http://www.daisyrust.com/wp-content/images/bluetooth_02-1.png','popup','width=595+20,height=468+20,scrollbars=no,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=yes,left=0,top=0');return false" href="http://www.daisyrust.com/wp-content/images/bluetooth_02-1.png"><img src="http://www.daisyrust.com/wp-content/images/bluetooth_02-1-tm.jpg" border="1" alt="Bluetooth 02-1" hspace="4" vspace="4" width="127" height="100" /></a></p>
<p>Here are the settings: the port name will be needed in the configuration file in the next step, so copy it!</p>
<p><a onclick="window.open('http://www.daisyrust.com/wp-content/images/bluetooth_03-1.png','popup','width=438+20,height=419+20,scrollbars=no,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=yes,left=0,top=0');return false" href="http://www.daisyrust.com/wp-content/images/bluetooth_03-1.png"><img src="http://www.daisyrust.com/wp-content/images/bluetooth_03-1-tm.jpg" border="1" alt="Bluetooth 03-1" hspace="4" vspace="4" width="104" height="100" /></a></p>
<p><strong>(c)</strong> Edit the UltraSMS Configuration file (utlrasms.conf) to point to the newly created database, sample below your details may vary.</p>
<blockquote>
<pre><code>
DEVICE = "/dev/tty.Torme-SerialPort-1"
DAEMON = "FALSE"
DEBUG = "FALSE"
MYSQL_HOST = "localhost"
MYSQL_DB = "ultrasms"
MYSQL_USER = "root"
MYSQL_PASS = "[insert your mysql password]"
</code></pre>
</blockquote>
<p>You put this conf into the /etc/ directory.</p>
<p><strong>(d)</strong> Start the daemon.</p>
<p><img src="http://www.daisyrust.com/wp-content/images/start_daemon.png" border="1" alt="Start Daemon" hspace="4" vspace="4" width="388" height="114" /></p>
<p><strong>(e)</strong> Wait for a text!</p>
<p><strong>(f)</strong> Voila! Message Received</p>
<p><a onclick="window.open('http://www.daisyrust.com/wp-content/images/daemon_receives_message.png','popup','width=503+20,height=364+20,scrollbars=no,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=yes,left=0,top=0');return false" href="http://www.daisyrust.com/wp-content/images/daemon_receives_message.png"><img src="http://www.daisyrust.com/wp-content/images/daemon_receives_message-tm.jpg" border="1" alt="Daemon Receives Message" hspace="4" vspace="4" width="138" height="100" /></a></p>
<p><strong>(g)</strong> The SMS data is automatically inserted the database.</p>
<p><a onclick="window.open('http://www.daisyrust.com/wp-content/images/database_result.png','popup','width=865+20,height=892+20,scrollbars=no,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=yes,left=0,top=0');return false" href="http://www.daisyrust.com/wp-content/images/database_result.png"><img src="http://www.daisyrust.com/wp-content/images/database_result-tm.jpg" border="1" alt="Database Result" hspace="4" vspace="4" width="96" height="100" /></a></p>
<p><strong>(h)</strong> The next step is to do something cool with the data!</p>
<p><strong>Conclusions</strong></p>
<p>I favour <strong>option (3)</strong>. Physical access to a server is not always possible and so this solution is ideal for art installation scenarios where one has hands on access to a web-server setup.</p>
<p>Option (1) - is great but finding an inexpensive service, of an appropriate scale and that is reliable has so far eluded me. I will update this view when <a href="http://www.tm4b.com">www.tm4b.com</a> get back to me.</p>
<p>The next tutorial, Public Art and Interactivity using SMS: a prototype, will demonstrate how to integrate a flickr search with the ultraSMS and MySQL process elaborated in Option 3.</p>
<p><strong>Ian Grant</strong></p>
<p><strong>Further Links</strong></p>
<p><a href="http://www.mediamatic.net/artefact-200.9203.html">Flickr Peep Show</a><br />
<a href="http://www.textually.org/">http://www.textually.org/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.daisyrust.com/2006/03/24/basic-telematics-using-sms-and-the-web/feed/</wfw:commentRss>
		</item>
		<item>
		<title>searching and returning images from flickr</title>
		<link>http://www.daisyrust.com/2006/02/05/public-screens-searching-and-returning-images-from-flickr-via-sms/</link>
		<comments>http://www.daisyrust.com/2006/02/05/public-screens-searching-and-returning-images-from-flickr-via-sms/#comments</comments>
		<pubDate>Sun, 05 Feb 2006 16:45:56 +0000</pubDate>
		<dc:creator>ian grant</dc:creator>
		
		<category><![CDATA[digital art hacks]]></category>

		<category><![CDATA[telematics]]></category>

		<category><![CDATA[web 2.0]]></category>

		<guid isPermaLink="false">http://www.daisyrust.com/2006/02/05/public-screens-searching-and-returning-images-from-flickr-via-sms/</guid>
		<description><![CDATA[An introductory article on searching flickr and returning the images using php, phpFlickr and (optionally) a mySQL database.]]></description>
			<content:encoded><![CDATA[<p>A number of people need to get searching flickr, returning and displaying images according to tag or full-text searches and handling associated tags. Although it seems a long process, this tutorial demonstrates one way to approach flickr that is simple and flexible.<span id="more-10"></span> With application and extension, you can use the contents here to play a part in projects that:</p>
<p>- utilise user input to get images from flickr. &#8216;User input&#8217; could come from web forms or,  like &#8216;Play Flickr&#8217;, from mobile phone SMS messages.<br />
- search and display flickr images from script-based lists of words and associations. Select search terms by semantic analysis (meaning) or other random principles. You could use &#8216;get related tag functions&#8217; as demonstrating in <a href="http://ellington.tvu.ac.uk/ina/blog/wp-content/code/phpFlickr_search_002_red.php">phpFlickr_search_002_red.php</a>.<br />
- store image search result data in a mysql database or in a text file to use in flash</p>
<p><strong>This tutorial requires:</strong><br />
PHP 4 (or higher), phpFlickr (a library available from <a href="http://www.phpflickr.com/">http://www.phpflickr.com/</a>)<br />
<strong>Optionally Uses:</strong><br />
A mysql database to speed up server responses by using a &#8216;cache&#8217; or a file system cache (a plain text document)<br />
<strong>Basic Requirements:</strong> server access with php; free flickr account and flickr API key; ftp program, a good text editor or dreamweaver 20mins.</p>
<p>Instead of getting down and dirty with flickr&#8217;s own api directly, <a href="http://www.phpflickr.com/">phpFlickr</a> is a class written by Dan Coulter that hides most of the complexity and, through simple examples, allows elaborate interactions with flickr. There are easy to adapt examples on his website and the documentation is great (see: <a href="http://www.phpflickr.com/docs/">http://www.phpflickr.com/docs/</a>)</p>
<p>A number of projects I&#8217;ve seen depend on returning images from flickr after searching for a keyword, a tag, a cluster name etc&#8230; In this example the search term (red, summer, winter) is hard coded into the php. You could supply these terms in many ways. A future tutorial will demonstrate using an array of search terms.</p>
<p>Click below to see what the demo files we are looking at produce:</p>
<p><strong>Link:</strong> <a href="http://ellington.tvu.ac.uk/ina/blog/wp-content/code/phpFlickr_search_001.php">phpFlickr_search_001.php</a><br />
<strong>Link:</strong> <a href="http://ellington.tvu.ac.uk/ina/blog/wp-content/code/phpFlickr_search_002_red.php">phpFlickr_search_002_red.php</a></p>
<p><strong>Download the source files:</strong> <a href="http://ellington.tvu.ac.uk/ina/blog/wp-content/code/phpFlickr_Tutorial_Files_001.zip">phpFlickr_Tutorial_Files_001.zip</a></p>
<p>Before you get going, there are several basics to get started:</p>
<p><strong>First Steps</strong></p>
<p>(1) Sign up for a free flickr account (<a href="http://www.flickr.com">http://www.flickr.com</a>)<br />
(2) Get a flickr API key associated with that account (<a href="http://www.flickr.com/services/api/key.gne">http://www.flickr.com/services/api/key.gne</a>)<br />
<img src="http://ellington.tvu.ac.uk/ina/blog/wp-content/images/flickr_api_key.png" height="369" width="400" border="1" hspace="4" vspace="4" alt="Flickr Api Key" /><br />
image: get a flickr api key after setting up a free account.</p>
<p>(3) download phpFlickr (<a href="http://www.phpflickr.com/">http://www.phpflickr.com/</a>) and upload it to a directory on a php enabled webserver (eg. <a href="http://zappa.tvu.ac.uk">zappa.tvu.ac.uk</a>)</p>
<p><strong>Important Note:</strong><br />
Copying and pasting the coloured code may not work. Wordpress and the colour syntax highlighter occasionally messes up some of the characters particularly some angle brackets (>). So: -> becomes -/> and that breaks the php. Download the zipped files and use the coloured code as a broad indication of the scripts flow. You will need to edit the code to get things working. Details below.</p>
<p>You will make reference to a &#8216;magic&#8217; file (phpFlickr.php) in that directory in any script you write where you wish to use flickr resources in your web pages. eg. This code &#8216;includes&#8217; the functionality in any page you write:</p>
<p><code><br />
[php]< ?php<br />
require_once("phpFlickr/phpFlickr.php"); // the path to the file must be accurate<br />
?><br />
[/php]<br />
</code></p>
<p>Including this file does a lot of the work for you, you just then have to learn how to use the function calls and how to do with the results the calls &#8216;return&#8217;. Although this looks complicated, desconstructing the sample code is relatively simple. </p>
<p>Here is an example php script, adapted from an example on the phpflickr page that uses phpFlickr to search for images sorted by &#8216;interestingness&#8217; - a useful category for returning pictures selected using flickr&#8217;s own sorting algorithms </p>
<p><code><br />
<?php<br />
require_once("phpFlickr/phpFlickr.php");<br />
// Create new phpFlickr object<br />
$flickr_object = new phpFlickr("[insert your flickr api key]");<br />
// Enable transparent caching.<br />
$flickr_object->enableCache(<br />
    &#8220;db&#8221;,<br />
    &#8220;mysql://root:torme@localhost/phpflickr_cache&#8221;<br />
);</p>
<p>echo &#8220;
<p>Most interesting photos tagged with \&#8221;red\&#8221;:<br />\n&#8221;;<br />
// Search by the single tag &#8220;red&#8221;<br />
$photos_red = $flickr_object->photos_search(array(&#8221;tags&#8221;=>&#8221;red&#8221;, &#8220;sort&#8221;=>&#8221;interestingness-desc&#8221;, &#8220;per_page&#8221;=>6));<br />
foreach ($photos_red['photo'] as $photo) {<br />
    // Build image and link tags for each photo tagged with &#8216;red&#8217;<br />
    echo &#8220;<a href=http://www.flickr.com/photos/$photo[owner]/$photo[id]>&#8220;;<br />
    echo &#8220;<img border='0' alt='$photo[title]' ".<br />
        "src=" . $flickr_object-/>buildPhotoURL($photo, &#8220;Square&#8221;) . &#8220;>&#8221;;<br />
    echo &#8220;</a>&#8220;;<br />
}<br />
echo &#8220;</p>
<p>\n&#8221;;</p>
<p>?><br />
</code></p>
<p><small>file: <a href="http://ellington.tvu.ac.uk/ina/blog/wp-content/code/phpFlickr_search_002_red.php">phpFlickr_search_002_red.php</a></small></p>
<p><strong>Step by Step Walkthrough</strong><br />
<strong>(1)</strong> and <strong>(23)</strong> Open and closing php tags.</p>
<p><strong>(2)</strong> require_once includes the phpFlickr library. We do not need to touch (or understand) the contents of this referenced file. That said, take a look inside the file and you will find better documentation for each function. </p>
<p>The url needs to point to the correct place though. If you do look in phpFlickr.php you will find definitions of all the classes and functions available for playing with flickr. It does a lot more than this example. Note that you pass in the flickr API key. I have taken mine out. You paste yours in this space.</p>
<p><strong>(4)</strong> Create a flickr &#8216;object&#8217; and assign it to a variable. Doing things with (technically &#8217;sending messages to&#8217;) &#8216;$flickr_object&#8217; will achieve the responses we need. An example of such a message is seen in line 12.</p>
<p><strong>(6-9)</strong> An optional block that enables great speed enhancements. To take advantages of this you need access to a mysql database. If you have such access the only details you are likely to need to change are as indicated: mysql user name, password, and database name. When the script first runs it populates the existing database with all the tables and data the script will need the next time it runs. It will then not call to flickr, search and fetch images, rather look in your local database - speeding things up significantly. </p>
<p><img src="http://ellington.tvu.ac.uk/ina/blog/wp-content/images/mysql_phpmyadmin.jpg" height="304" width="400" border="1" hspace="4" vspace="4" alt="Mysql Phpmyadmin" /><br />
<small>image: using phpMyAdmin to create a database</small></p>
<p>If you don&#8217;t have access to a mysql database, you can change lines 6-9 to:</p>
<p><code><br />
<?php<br />
 $flickr_object->enableCache(&#8221;fs&#8221;, &#8220;phpFlickrCache&#8221;); // fs stands for file system. phpFlickrCache is a directory with permissions of 777<br />
?><br />
</code></p>
<p>This will &#8216;cache&#8217; [store] the flickr data to a flat text file on your webserver. You must set the permissions on the target directory allowing the webserver &#8216;write access&#8217;. Permissions set at 777 is overkill but good for troubleshooting. Use a good ftp program to set permissions on directories or files. More info on phpflickr caching at <a href="http://www.phpflickr.com/docs/caching/">http://www.phpflickr.com/docs/caching/</a></p>
<p><img src="http://ellington.tvu.ac.uk/ina/blog/wp-content/images/project_dir_and_permissions_fpt.jpg" height="443" width="400" border="1" hspace="4" vspace="4" alt="Project Directory and Changing Permissions Using and FTP Program" /><br />
<small>Image: Changing directory permissions using and ftp program</small></p>
<p><strong>(11)</strong> This begins &#8216;printing&#8217; or echoing html out from php to the web page that the end user eventually sees. There are rules to how this happens. Studying the php manual will help <a href="http://uk.php.net/manual/en/function.echo.php">http://uk.php.net/manual/en/function.echo.php</a>. Errors can creep into your php AND in the html. Hence, a familiarity with html is very helpful. There are other ways to do this where the html does not get embedded after an echo command and between quotation marks. Ask me for some tips!</p>
<p><strong>(13)</strong> Note the use of variables. This is where our phpflickr &#8216;object&#8217; is sent a list of messages:<br />
in English -<br />
- go to flickr and search for pictures where the image is tagged &#8216;red&#8217;.<br />
- Sort results by &#8216;interestingness&#8217; descending (meaning most interesting ones first).<br />
- Send us back six results.<br />
In computer jargon, the &#8216;list of messages&#8217; is an array of parameters expressed as &#8216;key-value pairs&#8217;: eg. tags => red is a &#8216;key-value pair&#8217; where &#8216;tags&#8217; is the key and &#8216;red&#8217; is the value associated with that key. So we pass messages to the object using an array. </p>
<p>Look up these terms, particularly &#8216;arrays&#8217; to understand them further. Although you don&#8217;t need to understand them to get these examples to work, manipulating arrays is central to getting phpflickr to &#8216;return&#8217; what you want. The results are sent as an array, technically an array of arrays or an associative array. Don&#8217;t get scared but here is an ugly, full example. It should be clear from the data represented here, what may be going on behind the scenes of our little search script.</p>
<p><code><br />
Array<br />
(<br />
    [_name] => photos<br />
    [_attributes] => Array<br />
        (<br />
            [page] => 1<br />
            [pages] => 23835<br />
            [perpage] => 6<br />
            [total] => 143009<br />
        )</p>
<p>    [_value] =><br />
    [page] => 1<br />
    [pages] => 23835<br />
    [perpage] => 6<br />
    [total] => 143009<br />
    [photo] => Array<br />
        (<br />
            [0] => Array<br />
                (<br />
                    [_name] => photo<br />
                    [_attributes] => Array<br />
                        (<br />
                            [id] => 53363322<br />
                            [owner] => 93291046@N00<br />
                            [secret] => 03c1a1c6a2<br />
                            [server] => 27<br />
                            [title] => Er-Liao/Ã¤ÂºÅ’Ã¥Â¯Â®<br />
                            [ispublic] => 1<br />
                            [isfriend] => 0<br />
                            [isfamily] => 0<br />
                        )</p>
<p>                    [_value] =><br />
                    [id] => 53363322<br />
                    [owner] => 93291046@N00<br />
                    [secret] => 03c1a1c6a2<br />
                    [server] => 27<br />
                    [title] => Er-Liao/Ã¤ÂºÅ’Ã¥Â¯Â®<br />
                    [ispublic] => 1<br />
                    [isfriend] => 0<br />
                    [isfamily] => 0<br />
                )</p>
<p>            [1] => Array<br />
                (<br />
                    [_name] => photo<br />
                    [_attributes] => Array<br />
                        (<br />
                            [id] => 57472700<br />
                            [owner] => 78637845@N00<br />
                            [secret] => ab2bf469ff<br />
                            [server] => 24<br />
                            [title] =><br />
                            [ispublic] => 1<br />
                            [isfriend] => 1<br />
                            [isfamily] => 1<br />
                        )</p>
<p>                    [_value] =><br />
                    [id] => 57472700<br />
                    [owner] => 78637845@N00<br />
                    [secret] => ab2bf469ff<br />
                    [server] => 24<br />
                    [title] =><br />
                    [ispublic] => 1<br />
                    [isfriend] => 1<br />
                    [isfamily] => 1<br />
                )</p>
<p>            [2] => Array<br />
                (<br />
                    [_name] => photo<br />
                    [_attributes] => Array<br />
                        (<br />
                            [id] => 30706255<br />
                            [owner] => 66668382@N00<br />
                            [secret] => 4a21314a00<br />
                            [server] => 23<br />
                            [title] =><br />
                            [ispublic] => 1<br />
                            [isfriend] => 1<br />
                            [isfamily] => 1<br />
                        )</p>
<p>                    [_value] =><br />
                    [id] => 30706255<br />
                    [owner] => 66668382@N00<br />
                    [secret] => 4a21314a00<br />
                    [server] => 23<br />
                    [title] =><br />
                    [ispublic] => 1<br />
                    [isfriend] => 1<br />
                    [isfamily] => 1<br />
                )</p>
<p>            [3] => Array<br />
                (<br />
                    [_name] => photo<br />
                    [_attributes] => Array<br />
                        (<br />
                            [id] => 37360829<br />
                            [owner] => 48819593@N00<br />
                            [secret] => 5f30fdefd6<br />
                            [server] => 25<br />
                            [title] => `Nu York Parallax`<br />
                            [ispublic] => 1<br />
                            [isfriend] => 0<br />
                            [isfamily] => 0<br />
                        )</p>
<p>                    [_value] =><br />
                    [id] => 37360829<br />
                    [owner] => 48819593@N00<br />
                    [secret] => 5f30fdefd6<br />
                    [server] => 25<br />
                    [title] => `Nu York Parallax`<br />
                    [ispublic] => 1<br />
                    [isfriend] => 0<br />
                    [isfamily] => 0<br />
                )</p>
<p>            [4] => Array<br />
                (<br />
                    [_name] => photo<br />
                    [_attributes] => Array<br />
                        (<br />
                            [id] => 23471561<br />
                            [owner] => 78527758@N00<br />
                            [secret] => 90486d5d23<br />
                            [server] => 16<br />
                            [title] => How can I put into words what I feel?<br />
                            [ispublic] => 1<br />
                            [isfriend] => 0<br />
                            [isfamily] => 0<br />
                        )</p>
<p>                    [_value] =><br />
                    [id] => 23471561<br />
                    [owner] => 78527758@N00<br />
                    [secret] => 90486d5d23<br />
                    [server] => 16<br />
                    [title] => How can I put into words what I feel?<br />
                    [ispublic] => 1<br />
                    [isfriend] => 0<br />
                    [isfamily] => 0<br />
                )</p>
<p>            [5] => Array<br />
                (<br />
                    [_name] => photo<br />
                    [_attributes] => Array<br />
                        (<br />
                            [id] => 36145605<br />
                            [owner] => 51035555243@N01<br />
                            [secret] => 1901c66046<br />
                            [server] => 24<br />
                            [title] => Mars<br />
                            [ispublic] => 1<br />
                            [isfriend] => 1<br />
                            [isfamily] => 1<br />
                        )</p>
<p>                    [_value] =><br />
                    [id] => 36145605<br />
                    [owner] => 51035555243@N01<br />
                    [secret] => 1901c66046<br />
                    [server] => 24<br />
                    [title] => Mars<br />
                    [ispublic] => 1<br />
                    [isfriend] => 1<br />
                    [isfamily] => 1<br />
                )</p>
<p>        )</p>
<p>)<br />
</code><br />
<strong>[See Note 1]</strong><br />
If we increased the images to be returned from 6 to 10, the photo array would contain elements numbered 0-9 rather 0-5. Note other pieces of information contained in the response that could be used to build more queries: eg. page number and total pages, image titles.</p>
<p>See: for more on associative areas <a href="http://en.wikipedia.org/wiki/Associative_array">http://en.wikipedia.org/wiki/Associative_array</a></p>
<p><strong>(14-20)</strong> Is a control structure (see: <a href="http://uk.php.net/manual/en/control-structures.foreach.php">http://uk.php.net/manual/en/control-structures.foreach.php</a>) that loops through each result sent back and, using the same method as (11) prints out html containing our search results. In this case, the results are returned as &#8217;square&#8217; thumbnails that are links to the full image on flickr [Note 2].<br />
Check out an image on flickr and investigate the structure of the url. That will help to explain the url construction within the &#8216;a&#8217; html tag.</p>
<p>To display the thumbnail image we use the html image tag:<br />
<code><img border = "0" src="IMAGE URL HERE" alt="some text about our picture /><br />
</code></p>
<p>but the image source is constructed simply by calling the function in the following snippet:</p>
<p><code>$flickr_object->buildPhotoURL($photo, "Square")</code></p>
<p>where $photo is each photo sub-array of the array called photo!! PhpFlickr protects us from this complexity. The function does the tricky business of walking through the array and producing the photo source url from the correct key-value pairs. All behind the scenes!</p>
<p>(21) Closes the open paragraph tag, completing the html code block. Make sure you always construct valid html.</p>
<p><strong>Conclusions</strong><br />
This draws to a close this walkthrough.<br />
We demonstrated how phpFlickr, with the right preparation, can use short, elegant scripts to do complex searching of flickr, array crunching and performance-enhancing caching. We saw easy integration with mysql databases and flat text files. We say the ease with which php can write html out for a web browser.</p>
<p><strong>For the more curious: </strong><br />
<strong>(a)</strong> take a look at the way the returned data is stored both in the mysql tables (you will need access to phpMyAdmin or another similar tool). How easy would it be to get flash working with this data? How could you use phpFlickr as a bridge between flickr and flash?<br />
<strong>(b)</strong> Try to use and create arrays of words in php to automatically return images according to those words and, maybe, the associated tags. </p>
<p><strong>Notes<br />
Note 1:</strong> Adding this php snippet after line 13 will print out the array structure - good for debugging and general information.<br />
<code><br />
echo "
<pre>\n";
print_r($photos_red);
echo "</pre>
<p>&#8220;;<br />
</code></p>
<p><strong>Note 2: </strong>Looking at the source code of phpFlickr (confirmed by the documentation of the flickr api) one can discover that we could use any of the following image sizes/shapes in this function: square, thumbnail, small, medium, large, or original. Medium is the default size.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.daisyrust.com/2006/02/05/public-screens-searching-and-returning-images-from-flickr-via-sms/feed/</wfw:commentRss>
		</item>
		<item>
		<title>safari2delicious</title>
		<link>http://www.daisyrust.com/2005/10/28/safari2delicious/</link>
		<comments>http://www.daisyrust.com/2005/10/28/safari2delicious/#comments</comments>
		<pubDate>Fri, 28 Oct 2005 20:04:21 +0000</pubDate>
		<dc:creator>ian grant</dc:creator>
		
		<category><![CDATA[creative code]]></category>

		<category><![CDATA[mac]]></category>

		<category><![CDATA[safari]]></category>

		<category><![CDATA[web 2.0]]></category>

		<guid isPermaLink="false">http://www.daisyrust.com/2006/02/10/safari2delicious-transfer-bookmarks-from-safari-to-delicious/</guid>
		<description><![CDATA[<p style="text-align:left"><img align="left" id="image29" src="http://www.daisyrust.com/wp-content/uploads/2006/02/safari-logo2.png" alt="safari2delicious logo" /></p>visit: <a href="http://www.daisyrust.com/dev/safari2delicious/" alt="import safari bookmarks to delicious">www.daisyrust.com/dev/safari2delicious/</a>

<b>transfer bookmarks from safari to delicious</b>
a personal hack gone public.]]></description>
			<content:encoded><![CDATA[<p style="text-align:left"><img align="left" id="image29" src="http://www.daisyrust.com/wp-content/uploads/2006/02/safari-logo2.png" alt="safari2delicious logo" /></p>
<p><b>visit:</b> <a href="http://www.daisyrust.com/dev/safari2delicious/" alt="import safari bookmarks to delicious">www.daisyrust.com/dev/safari2delicious/</a></p>
<p><b>transfer bookmarks from safari to delicious</b></p>
<p>a personal hack gone public. a web based step-through to transfer safari bookmarks to a named delicious account. you have full control over tags and what urls are uploaded. it is not necessarily designed for large collections and it benefits from having named urls already organised in folders in the safari bookmark manager. For me it was very useful to generate tags from nested folders. safari2delicious will apply tag to all imports to allow management of imports in the delicious environment. I hope this hack gets outmoded by a more elegant service from delicious.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.daisyrust.com/2005/10/28/safari2delicious/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
