0

I already have a published app in both iOS and Android using Cordova. I'm using PHP scripts to retrieve and send data from server. Both platforms use same PHP script. I send data using XML. And call this script using AJAX.

a sample ajax call :

jQuery.ajax({
                          url: 'http://www.example.net/example.php',  //load data 
                          global: false,
                          type: "POST",
                          dataType: "xml",
                          async: true,
                          beforeSend: function() {
                            $('#loading').show();
                          },
                          complete: function(){
                            $('#loading').hide();
                          },
                          success: loading_complete_list,
                          error: errorfunc
                    });

Problem is I have to send some platform specific data. That means I need to send some specific data for ANDROID. I can't change app code as user may or may not update the app. So I have to change the PHP script such a way that it'll detect the ajax requesting platform or browser and send specific data. So far I know that iOS and Android uses specific webview such as safari or chromium. So if I can at least detect the requesting browser I can detect the platform.

Please remember I can't change app code as it's already published and I can't force user to update. Thus it has to be detected using the PHP script.

I tried searching detect browser using php for ajax call, but no luck so far. Is it possible to detect browser / platform through ajax call in PHP? If so then how?

AtanuCSE
  • 8,832
  • 14
  • 74
  • 112

1 Answers1

0
echo $_SERVER['HTTP_USER_AGENT'] . "\n\n";

$browser = get_browser(null, true);
print_r($browser);
Sanjay Kumar N S
  • 4,653
  • 4
  • 23
  • 38
  • No I can't. I'm written in my question clearly that I can't modify app code, JS code can't be changed. It has to be identified by PHP only. no passing. – AtanuCSE Apr 27 '15 at 06:39