Web service PHP + Android application - php

Using eclipse i create a simple abdroid application which communicate with MYSQL data base using PHP scripts, i start writing my PHP Web Service and i put those files under 'www' of my Wamp server.
in fact Wamp server is using two servers
1.web server ( Apache)
2.Mysql
after doing those steps i run my android application under eclipse ide and i get all things works..
I m trying to understand the process behind all that.
My Android application by runnig send an HTTP request to the PHP web service, then ,the apache Web server in Wamp Server executes the php script and do some oparation on the data base ,after that the result is reterning to the Android application ( the result in Json format), and finaly the application decode the Json object and display the result
is it right? please correcte me if i m wrong

This is correct if you want it to be a simple request-driven web service (such as HTTP in your case).

Related

how to connect my cordova app to an existing web server containing php files

I'm new to working with real web servers
I developed my Cordova app and used PHP files using XAMPP to provide web servers
but now I want to publish the app and I have a fully functional web server
how can I access the PHP files (I already put in this web service) using the POST method (found in my index.js file in my Cordova app)?
I tried changing the URL in the ajax post request
from http://localhost/config.php for example
to http://IP_OF_WEB_SERVER/config.php
but it's giving a connection timeout
how can I get this to work?
Am I missing something?
The question isn't very clear. You can't access your webserver from cordova, or you want to load a php file inside cordova?
The apache cordova doesn't support the usage of php, and another thing is that you can't use the localhost directly. You can use the inappbrowser plugin or ajax to fetch your contents from a remote web server.
In the first case with the plugin, you only need to specify the web address of your webserver that host your app .php files. With ajax instead you need to set some rule of the default content security policy that is shipped when a cordova app is build.

Connecting PHP Web Service and ASP.NET website to same MySQL

I created a website using ASP.net and it's accessing MySQL through visual studio using IIS and there are some web services developed in PHP [tested using Apache Server] for the android application. Now, I am able to run both Asp.net website and android application using the same host by running both the servers on the same machine.
But how can I use the same MySQL database for both the purposes. How can I redirect the requests for both asp.net web services and php requests to the same database?
It depends, but generally, connection strings in Asp.Net are stored in a file called web.config, in the root folder of the application.
I don't know if php have a central place to store connection strings, but in both cases you need to change that.

Create and consume web service on local machine by using WAMP

Is it possible to create an environment on local machine( i.e. localhost) where we can create and consume web service using PHP?
Is there any flow to create a web service like environment on localhost?
I would like to create an environment on localhost for web services where local machines, on intranet, get connected to main server (here again it's local machine) and can consume web services.
Like on internet we have Web Servers from where we can create and consume web services, Can we do the same on localhost?
Edit:
I am using WAMP with
PHP 5.3 Apache 2.* MySQL 5Windows 8
It is easy to create a local web service. You will need a local web server (like IIS or xampp) to execute PHP locally.
Access you PHP application in your browser using http://localhost/<yourApp>.php and provide any webservice at a local URL as well, e.g. http://localhost/<yourService>.php. Your application can then access the webservice using the local URL.
This works both for REST or SOAP-style services.
EDIT: Your edit shows that you already set up a local environment to develop and test webservices. You should really be more specific in your question, maybe you are looking for a tutorial to create web services with PHP in genereal. If so, Google will be your best friend: https://www.google.de/#q=create+web+service+using+php+tutorial

How to make a php file in bluehost that is reachable from ios app and mysql

I have already made my app so that it works on the ios simulator and a localhost server. Now I want to make my app so that it is reachable on ios devices. I have a website that is hosted by bluehost. If I could just write up the same php files that I wrote in the local server and it was reachable from the app and mysql, I think it would do the trick. Unfortunately, I don't know how to do this. Is there a way to access my website's mysql from my ios app through php files (which are also on bluehost)?
Thanks in advance!
You need one of the three (well you can make your own mode as well, but these are standard)
JSON
XML
CSV
Your php file on bluehost would be an URL which would open a stream and push information from the database and your IOS app needs to read it.

How do I add PHP files to my android APK file?

I have a web application that uses both localstorage but also server side SQL storage. When I test my APK file using Eclipse only the html pages with localstorage work and not the server stuff in the PHP files. How can I direct my PHP files to go to a server since all the APK does it package everything on the client side?
Thanks
You can run PHP on Android. Try SL4A. Web servers can exist on a mobile. There are quite a few that function as a local server, within Android apps.
You can't run php files on mobile except on the browser
So if you want to run PHP files put them on the server and invoke them to return or accept data from you
To run PHP files you need a web server which doesn't exist on a mobile
I believe that you asked this because you could run javascript & HTML files on the mobile
I will recommend two things
1- If you need to run PHP make ana AJAX request on it and keep it on the server and remember the cross-domain
2- you need to consider the performance of the app you are making because after personal experience its slow
One More thing it works on the chrome because you have a web server (APACHE) on your machine

Categories