0

I just want to know whether we can differentiate the user request. I mean, I would like to render the pages according to the request. If the request comes from iPhone/iPad/Android then I will display the pages designed accordingly. Else I will display the normal HTML page.

I am not sure, if we can find out the type of the user based on the request. Can anyone help me out by posting some ideas ?

serenity
  • 159
  • 1
  • 3
  • 16

3 Answers3

3

I think you're asking:

Q: How can a web server identify the client platform?

A: There's no SURE way to do this.

Your best bet is to look at the http header from the client request. Specifically, look at the "user-agent". Here's a link with a similar question:

Is it possible to identify Android apps from http headers?

Here are three examples:

http://www.askdavetaylor.com/detect_apple_iphone_user_web_site_server.html

1) IE, from a Windows PC:

HTTP_USER_AGENT=Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)

2) An Apple iPhone with Safari:

HTTP_USER_AGENT=Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en)
AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1C25 Safari/419.3

3) An Android phone:

Moxilla/5.0 (Linux; U; Android 2.2; en-us; T-Mobile G2 Build/FRF91) AppleWebKit/533.1(KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
Community
  • 1
  • 1
paulsm4
  • 114,292
  • 17
  • 138
  • 190
  • Paulsm4, I understand that we can perform the above tasks if we would like to pull the details regarding the user who is accessing the weblink from the mobile browswers, however, my intention is specific mobileApp (iPhone App or Android App or iPad App). Can we find out whether the user is accessing the application from the Android/Iphone/iPad App. – serenity Jan 12 '12 at 15:33
1

Sniffing the user-agent is a common technique, like this for example:

User-Agent Sniffing

Pedro Rio
  • 1,444
  • 11
  • 16
1

You can use media queries if it's just a case of different CSS

Adaz
  • 1,627
  • 12
  • 14