The Guardian launch Open Platform

The Guardian released their own version of the New York Times’s open API today. Supporting various languages, including PHP, it looks like a large collection of the newspaper’s back-catalogue will be available for all to search to their hearts content.

As with pretty much every other major public API, you’ll need to get an access key before you can query against the API. But once you’ve got that all you need to do to get some data back, is make a request against http://api.guardianapis.com/content/search?q={keywords}.

Appears you can request it to return XML, JSON or ATOM formats, so it’s pretty damn flexible too! I look forward to the stream of new apps that’ll be leaping to utilize this. Maybe even a Twitter/Guardian comparative mashup.

Read

Our Global Village

A while back (actually too long than I care to think) I wrote my degree dissertation on the distention of technology within modern society; examining it’s impact, state and future. My examination was in part to technology as a whole, but in the majority it was focused on the internet and it’s rapid evolution and uptake in society.

One of the most poignant references in my work was to Marshall McLuhan’s work. I recall being fascinated by his idea and discussion of the “Global Village”: How the world has shrunk through advent of communication and transport technologies. Allowing societies to traverse distances or time, without the constraints or considerations of previous generations. His work, to me, seemed to echo not only the evolutionary movement of technology as a whole, but very specifically that of the web and related social trends.

A few years after my graduation Facebook arrived on the scene, surpassing all previous efforts (MySpace, Friends Reunited) and really hammering home the claustrophobia of the modern, digital world. Other technologies quickly followed suit: cloud computing, the iPhone, public open Wi-Fi, cheap GPRS. To a point where information is not just at your fingertips, it’s in your pocket, plugged into your ears, quietly following you down the road via satellite streams.

Now, of course, this doesn’t sound like a bad thing. Amazon, Google and Facebook certainly wouldn’t want you thinking so either. Your friends are always there to chat when you need them, you can lookup the state of your finances on the way to work, via your iPhone, even make a few new friends via your out-of-body experience on Second Life. In fact life’s dandy for us information rich folk. But some of the arguments McLuhan made in both Global Village and Medium is the Message - which formed the core of my dissertation - seem to ring more loudly now than ever before.

To me, our increasing technological consumption, whilst decreasing the property of time, has substantially increased our abstraction from the physical world. The news regularly reports cases of online social events spilling, badly, into the real world. Marriages existing in Second Life, but failing in the real world, people being fired for status messages, even murders caused via state changes online. And these are almost always due to the inherent discontinuities between online and the real.

Don’t get me wrong, I think technologies like Google Latitude, Second Life, and all the others, are pioneers of the medium. But society needs to examine and learn from the digital mistakes we make now, rather than chasing the biggest cash or personal advancement. And I do wonder what mistakes will be made before we learn what to do with it all. The massive impact of technological contraction has already been felt on the financial world, and I can only wonder if increasing levels of youth crime can be, in-part, blamed on the increased social online activity of the younger generations and the removal of control/moderation/mentoring on such social platforms.

I think the next decade will be a very interesting one, but I for one, will be taking all these technologies with a substantial pinch of salt.

Read

PHP Proxy for Flash

Need to avoid the damn Flash cross-domain security restrictions?

I ran into numerous problems on a recent Flash build. Mainly as I was compiling via the FlexSDK on the command line and testing in an open browser. Not ideal, and I really hit some problems when cross-domain restrictions came to play.

Lucky for me Mr Apache and his best friend PHP came out to play, and I wrote a snippy little proxy class to request the files through. Bypassing the need for a cross-domain as all the files we’re being hosted on the localhost. Beauuutiful.

So in true Open Source style, here’s the proxy class in all it’s glory. A couple of things:

  • Ensure you’re running PHP5
  • You’ll need to view your SWF through the localhost. So on a Mac, that’s view the files via your site folder

The source code is below, otherwise download this ZIP: Proxy.php


requestURL = $queryVars[ self::$QUERY_URL ];
			$this->headers = isset($queryVars[ self::$QUERY_HEADER ]);

			if(isset($queryVars[ self::$QUERY_MIMETYPE ]))
			{
				$this->mimeType = $queryVars[ self::$QUERY_MIMETYPE ];
			}

			if( $this->startCurlSession() )
			{
				if ($requestType == self::$REQUEST_TYPE_POST) {
					$this->makePostRequest();
				}

				if($repsonse = $this->makeRequest())
				{
					if ($this->mimeType)
					{
						header("Content-Type: " . $this->mimeType);
					}
					echo($repsonse);
				}

				$this->stopCurlSession();
			}
		}
	}
	/**
	 * Initiates CURL session into current object
	 *
	 * @param	void
	 * @return	void
	 */
	private function startCurlSession ()
	{
		if($this->curlSession = curl_init($this->requestURL))
		{
			return(true);
		}
		return(false);
	}
	/**
	 * Closes current CURL session
	 *
	 * @param	void
	 * @return	void
	 */
	private function stopCurlSession ()
	{
		if(curl_close($this->curlSession))
		{
			return(true);
		}
		return(false);
	}
	/**
	 * Generates and commits CURL command to external server
	 *
	 * @param	void
	 * @return	string
	 */
	private function makeRequest ()
	{
		curl_setopt($this->curlSession, CURLOPT_HEADER, ($this->headers) ? true : false);
		curl_setopt($this->curlSession, CURLOPT_FOLLOWLOCATION, true);
		curl_setopt($this->curlSession, CURLOPT_RETURNTRANSFER, true);

		return(curl_exec($this->curlSession));
	}
	/**
	 * Creates POST headers (if needed)
	 *
	 * @param	void
	 * @return	void
	 */
	private function makePostRequest ()
	{
		$post_vars = Array();
		$ignore = Array( self::$QUERY_URL, self::$QUERY_MIMETYPE, self::$QUERY_HEADER);
		foreach($_POST as $key => $value) {
			if(!in_array($key, $ignore))
			{
				$post_vars[] = $key . '=' . $value;
			}
		}
		curl_setopt ($this->curlSession, CURLOPT_POST, true);
		curl_setopt ($this->curlSession, CURLOPT_POSTFIELDS, implode("&", $post_vars));
	}
}

// Instantiate
$cdpr = new CrossDomainProxyRequest( CrossDomainProxyRequest::$REQUEST_TYPE_GET );
?>
Read

Indexing a Flash site on Google

Our approach to Flash SEO (and accessibility)

There’s been alot of press lately regarding the new found viability of Flash and search indexing. Whether the improvements in the Flash player quantify to leaps in plug-in SEO or nothing more than than a puff in the wind.

In my opinion there’s little change in Flash SEO capabilities. Google have been indexing Flash files for sometime, and there’s been little formal evidence to suggest that a SWF can alter your search result position in anyway.

During a recent in-house project we came across this very issue and attempted to create our own style of Flash indexing for the site. After recent review it appears to be working brilliantly and has sucessfully managed to promote the indexing of textual content for each Flash page uniquely within Google search results.

The technical solution was a combination of Apache mod_rewrite, PHP (SimpleXML), SWFAddress (for SWFObject) and some bespoke JavaScript holding it all together. With the Flash site popualted via an XML document and utilizing SWFAddress to create a historical (back button) record of pages visited within the SWF. It was a case of converting the internal SWFAddress URIs (that use a standard hash technique that all AJAX based apps use) to a standard URL and preventing 404’s by mod_rewrite. Then once a URI is registered on the server, it serves up the index HTML with a parsed text-only version of the content, promoting indexing for search bots, and converting a standard URI to a hashed version via JavaScript (in the case that JS was activated and Flash was installed).

Whilst this approach may seem longwinded, it allowed us to generate an accessible, indexable site that offered the correct content delivery for relevant client platform (HTML or Flash). Improving the search ratings of the site and promoting deeplinked Flash pages.

Start Creative currently operates this system on their agency portfolio site, and I for one, am pretty proud of the achievement. Examples of the indexable links:
http://www.startcreative.co.uk/adidas/hub/
, http://www.startcreative.co.uk/bbc/case_02_dsdWebsite/

Read

Rambo

The Function Part Two

A while back I went through a phase where I was (mildly) obsessed with Rambo (prompted by the launch of the superbly violent John Rambo - i.e. Rambo 4). During this period I wrote a function entitled rambo which I decided to post on PHP.net for all to admire.

The destroyer of all variables, it was a method that could obliterate anything that was place in it’s path (or in it’s parenthesis as the case may be). Of course it was meant as joke, and after time I’ve even post-rationalised it to a piece of reflective coding art (maybe I’ll divulge later). What’s amazed me though is the wrath of distaste I’ve recieved from fellow coders. There’s been subsequent posts on PHP.net pointing out it’s faults and I’ve even recieved emails detailing what an ill concieved piece of coding it is.

As a result I’ve decided to post the beauty up here for all to enjoy (of course to their programming distaste) - abuse as you will!

(Original post - http://uk2.php.net/manual/en/function.unset.php#81839)

/**
 * function rambo (first blood)
 *
 * Completely and utterly destroys everything,
 * returning the kill count of victims
 *
 * @param    It don't matter, it’s Rambo baby
 * @return    Integer    Body count (but any less than 500 and
 *                   it's not really worth mentioning)
 */
function rambo() {

    // Get the victims and initiate that body count status
    $victims = func_get_args();
    $body_count = 0;      

    // Kill those damn punks
    foreach($victims as $victim) {
        if($death_and_suffering = @unset($victim)) {
            $body_count++;
        }
    }   

    // How many kills did Rambo tally up on this mission?
    return($body_count);
}
Read

Recent comments

  1. bo Couple of things: 1. When using tabs and say adding default value to two t...
  2. Rich I took a similar course at uni, and came across this interesting book... h...
  3. Cihat Hi good work thanks ...
  4. Matthew Cieplak This works great, except that it makes any pngs that happen to be hidden on...
  5. bahman Hello Dear OBAMA I am an iranian, I am very interested to you. I wish y...
Find