Reputation: 1362
I have a php page which connects an API and gets information back which can then be displayed.
I'd like to turn this into an app for Android. I've heard of PhoneGap, which I know uses javascript, html, and css. I know javascript is capable of calling php files, but I am unsure how or if its even possible to call a php file from an android device. I'm not sure if android browsers can handle php, or what the deal is with them. So if you have any information on that, I'd appreciate it.
I'm also willing to rewrite the API call in javascript, but I don't think thats possible. If you think differently, please let me know what you're talking about.
Upvotes: 1
Views: 557
Reputation: 73
I have done this with phonegap using jsonp http://en.wikipedia.org/wiki/JSONP Works great
Upvotes: 0
Reputation: 12705
1.It dosent matter to PhoneGap where the PHP is hosted or Its PHP OR ASP.NET OR ASP.NET MVC
2.If You wanna host your PHP code yourself in production (You mayb shouldn't do this in production). then you need a server and a static IP address
3.if you just wanna setup a PHP server for developmental purposes then just tie it to 127.0.0.1:81 and you can directly use this address it doesn't matter whether you have a static IP address or not.
Upvotes: 0
Reputation: 9762
PHP
is just a server side language so it doesn't matter if your browser "can or cannot" handle it, only HTML
is returned (unless you set a different content-type).
You may be worth while looking into REST
style JSON
api's which would allow a XMLRequest to be sent to. Have a look at this document
Theres also a nice tutorial here which shows how to call a REST
API and a PHP Tutorial here to create a REST
API.
Upvotes: 2
Reputation: 360762
Android cannot talk directly to PHP. What phonegap, javascript, etc.. are doing is simply issuing HTTP requests that happen to be handled by a PHP script.
The PHP code will execute, output some data (json, html, xml, gif, jpg, etc...) and send that out as a the HTTP request's reply.
Upvotes: 4