![]() |
Header Magic: Returning device specific contentFriday October 16th 2009 |
The great thing about Yahoo! Blueprint is that mobile web sites built on this platform will work on almost any mobile browser. Right now, the platform supports over 3500 devices, and this number is growing daily.
But even though Blueprint makes mobile web development so easy–there is only one code to write to cover all of the supported devices–there is still sometimes a need to deliver device specific content. For instance, a module that features videos should only be displayed on a phone that can actually play back videos. Or perhaps for an app store or consumables site that should only list items which will actually work on the user’s device.
Using Yahoo!’s request headers which are sent with every request to the developer’s server makes it possible to identify a device or even the device capabilities on the developer’s end. Depending on the header information, the developer can return optimized Blueprint XML back to Yahoo!’s infrastructure to get it rendered on the user’s phone.
The two most useful and most used headers are:
X-Device-Info
This header provides clear text information about the device maker, the model, and the operating system.
X-Device-Info: id=”4939392″; make=”Nokia”; model=”N95 8GB”; os=”Symbian”
X-Client-Accept
This header lists all the media types which are supported by the given browser. If you were to run a sports site that features a video section, for example, you may only want to return the Blueprint XML with the video section content when you see that the video media type is part of the X-Client-Accept header.
X-Client-Accept: video/, image/
Other headers can also be used to return region or language specific content. Please read the Headers section in the Blueprint documentation to see a full list of supported headers: http://developer.yahoo.com/mobile/blueprint/BPHTTPHeaders.html










