1

I want to let only Mobile App (iOS) to let data from my server side PHP Script I used HTTP_USER_AGENT here

$userAgent = $_SERVER['HTTP_USER_AGENT'];

It shows App Name, CF Network Info, Darwin OS Info

I got some info regarding HTTP transmission info utilizing this. But i need more detail.

Is there any way to get more details info regarding my app & only accept Mobile App (iOS) to get data from server side PHP script?

1
  • 2
    Are you trying to implement this as a security feature? I'm not aware of any was to verify that a device is running iOS that cannot be spoofed fairly easily... Commented Aug 29, 2012 at 5:10

4 Answers 4

1

About the only decent way to lock your server-side scripts to only mobile devices running your app is to implement HTTPS with client certificate validation.

Beyond this, anything that would indicate a device is running iOS could easily be sent from any device. The most obvious case here is running Safari on the device and accessing your scripts from there.

Sign up to request clarification or add additional context in comments.

Comments

1

We came across this problem in our app as well. Turns out the solution is actually quite simple.

There are only two steps:

1) Generate MD5 secret key once and store in app as a string (any MD5 key generate will do)

2) When making a POST (don't use GET, more safer) request to the web service, pass along this secret key

After you do that, your web service will know that the request was made from the app.

This method also has an extra benefits.

Let say you have two version of your app, paid and free, using a different MD5 secret key for each, you can identify whether it was the free or paid version that made the request.

1 Comment

+1 because it does provide a basic mechanism for restricting access. It probably needs SSL to be more secure and then you have to question how easy it would be for someone to decompile your mobile app to obtain the MD5 key. Regardless, this is a good solution if you're just trying to cut down on rampant use of the data but determined hackers can still get it so i wouldn't put anything too sensitive in your data if this is the solution you go with.
0

Try

$iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");

returns true if the browser is used from iPhone. I m not sure whether it works with third party browsers like chrome in iPhone.

Comments

0

That's is not 100% possible as Mobile Apps info can be emulated into browsers. Check Firefox Plugins.

But as a small check:

function isMobileiOS($useragent){
    if(stripos($useragent, 'iPod') !== false || stripos($useragent, 'iPhone') !== false || stripos($useragent, 'iPad') !== false){
        return true;
    }
    return false;
}

$mobile = isMobileiOS($_SERVER['HTTP_USER_AGENT']);

This will catch iOS devices.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.