How to target the Sony PSP user agent

So you have created PSP -specific content and have a beautiful PSP -sized content. Now what? How do you stop conventional browsers from viewing and using your PSP website? For example, the WorldVIEW website is for Playstation Portables only. If you visit that page in a regular browser, you will be greeted with a message telling you that the website is for PSPs only. How can you pull this off yourself? Its simple.

The PSP User Agent

A user agent is simple how a browser identifies itself and the operating system running it. If you check your website statistics, you will probably see lines like:

Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)

Which simply tells us that this particular user was on a computer running Windows NT 5.1 (which we all know is Windows XP), running Internet Explorer 6.0. This information allows you to track and manage what user agents are visiting your website. Similarly, the PSP also identifies itself as:

Mozilla/4.0 (PSP (PlayStation Portable); 2.00)

Now that we know how to target anyone using the Playstation Portable web browser, what do we do with it?

Deployment

There are two methods for identifying a specific user agent, and subsequently feeding that agent content. Client-side methods typically change the content after the page has been parsed by the browser. Experience has found that the Netfrontâ„¢ does not handle modifying the DOM well, and you may have limited success with a client-side implementation. We already know the user agent, so we will use this as a condition for writing specific content to the page:

if(navigator.userAgent.indexOf('PlayStation Portable') != -1)
{
document.write('This content is only seen on a Sony PSP using the NetFrontâ„¢ browser');
}

The server-side method of deployment revoloves around the unique headers that the PSP sends when it requests documents. Both “http_x_psp_productcode” and “http_x_psp_browser” can be used to target the PSP only.

if(isset($_SERVER['HTTP_X_PSP_BROWSER']))
{
echo('This content is only seen on a Sony PSP using the NetFrontâ„¢ browser');
}

These PHP snippets output some simple text only to a PlayStation Portable. You may have to add and modify as you see fit.

Leave a Reply