Which protocol to use for this application? - php

I want to code an Android client and a Windows.exe server application (possibly PHP., I am still trying to decide).
I have no problem with developing the server app, but have not yet done any Android coding. Mostly, though, I am unsure about how to communicate between client and server.
A client aapp will login to the server then at regular intervals send its location (GPS coords) to the server which will store the data in a MySql database,
A second Android app will display a historical trail of where the first user has been using Google maps, plus a little more functionality.
Since I am not serving HTML, I am wondering whether to use HTTP GET / POST or a proprietary protocol over TCP/IP. I would like to encrypt it, so SSL seems in order,
Is there any compelling reason to use one or the other of use HTTP GET / POST or a proprietary protocol over TCP/IP?
Would coding my Android app be easier if I used JSON as my data format (or something else?), irrespective of the protocl used to transfer the data?
Hmmm, since much of the data returned as a response to GET by one of the apps will be data used to draw a Google map with a series of points showing travel, could I do the heavy duty processing on the server & return the HTML (or JS) necessary to display it an dhave the app embedd a browser in its UI to display the map? (the UI will also disply more, but maybe I shoudl just make it browser based HTML & JS, rather thn an actual Jav Android app? As you can see, I am confused)
[Update] I want to code both the clients and the server and to host the MySql database. I would prefer no 3rd party frameworks unless they are excedding simply to use and play very well together with Delphi or PHP.

I may recommend you to use Wcf with poco entity that provide you security as you want and create client in android to consume it.here is simple example of using wcf in android-http://fszlin.dymetis.com/post/2010/05/10/Comsuming-WCF-Services-With-Android.aspx

I would strongly recommend the use of the newest Google Play Services with the Google Cloud Messaging... It takes out of you all that work.
Check out, see if you like ;D
Google Cloud Message: http://developer.android.com/google/gcm/index.html
There is also a great video of this year's Google I/O about the maps improvement on Google Play Services:
https://developers.google.com/events/io/sessions/325172829

Are you trying to create App that can be delivered from Google Play Store or a Andriod enable Web application? You Question is confusing in your need. If you are looking to create Andriod Apps then definitely PHP is not going to serve it up. Look for Andriod SDK and create your interface using that, then for Windows Server EXE you can do PHP based API or as suggested by other answers. But for User interface PHP is no. You need to read and understand the different between APP and Web App. or your question is not very clear on topic.

Related

Sending data to Google App Engine/Datastore

I have an Android app a Simple form consist of some fields, I also have a Web server using Google App Engine in PHP. I was confused by This, should i send the Data from my Android app directly to my webserver, display the data in web server using local and then later on update thus data in datastore or should i send the data from my android app directly to the datastore and display in my webserver? I'm new with this Android and with this Google App Engine/Datastore, I hardly can't find proper Tutorials on Google App Engine using php. I think only few uses this thing.
Any Suggestion well do.
The typical solution would be to provide an API for your app. I'm not familiar with PHP these days but there are bound to be plenty of REST frameworks that will take care of all the JSON conversion for you.
Your API (assuming it's PHP) can then take care of doing any necessary validation, authentication, performing queries, etc, against Datastore. This may help.
If you're familiar with Java (you're writing an Android app) or Python, you can look at Cloud Endpoints.
If you want a PHP library to access Datastore from GAE, check this out:
https://github.com/tomwalder/php-gds

From MySQL to Objective-C

I have a mysql database with informations about users. Now I want to work with them in my iPhone app. Is there a way to bring the stuff from mysql to objective-c?
It's not an option to use the mysql c api because my web server just allows php.
Greekings, Valle.
Your question is not very clear but maybe this can help:
You can serve the information from your database with PHP (some XML or JSON can be useful) and then parse it on your iPhone App.
Or you can export your database and convert it to SQLite and use it directly on your iPhone.
With a bit more information maybe we can give you a better answer.
It sounds like you want to create an Application Programming Interface (API), in PHP on the web server that your Objective-C program will talk to using the devices internet connection.
Effectively you want to create special url's and request parameters your web server will use to pull database information, parse them into JSON or XML, and return them as plain text.
Inside your Objective-C application you will craft these URL's and parse the incoming JSON or XML into actionable data for your app.
Well, I don't think you explained your problem very well. Shared web hosting solutions usually don't offer access to MySQL servers from outside, it means you can access only from their servers (like PHP scripts on your hosting).
Solution to this is usually simple web service - REST, XML-RPC, SOAP.
Web service is some application that can be written in PHP and is running on your web hosting. This application returns data (usually in XML or JSON) via specific URL.
Example:
From your native iPhone you call
http://yourserver.com/webservice/?what=episode-list&tvshow=battlestar-galactica
and output will be XML with list of episodes.

Building a native mobile application - based on a PHP web-app [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have had a PHP application developed. I want to use phonegap.com or a similar approach to develop native applications based on the same MySQL database. In other words, connect the mobile applications with the web one.
It needs to do one or two things differently. Firstly, use the native GPS features to determine where a user is - I'm guessing this can just be done via HTML5?
Secondly, send push notifications whenever the web-application user receives a notification.
All of the information is already there, on the MySQL database, and everything apart from the two features above function properly.
I'm am currently having an API developed for everything on the web-application - making it API-centric. In my head, it will be easy to connect the two versions via the API.
For example, a user signs up on the web application. He is then offered to iphone app for download.
Is it possible to get him to log-in with the same via the iPhone. On the other side, is it possible for him to search the database, via the iphone, and "add a new friend" - making the connection of the two users in the friends table - in that, the friend is also a friend on the web-application?
I've been reading a lot on all of the available options and am still very confused! Any help would be very helpful.
I'm not a phone developer myself, however I've just finished building a native Android App which connects to a website and is able to login, do stuff that is possible to do on the website as well. If the GPS tracking integration is using the native features than it is unlikely to use HTML5 (though I'm not sure how it works).
Basically in order to connect to a remote database/server you need to make HTTP requests from the phone to you server side script.
So just to conclude:
In order to achieve the result you're looking for the work-flow could look like this:
1.Mobile user fills a form ->
2.App does an HTTP request to a server side script ->
3.script does the hard work (e.g. connects to the database) ->
4.script renders a result ->
5.Mobile app displays the result.
I hope this helps.
Im my objective opinion there are three possibilities:
Get started with Objective-C
You will have to learn how to code and you will get the best native experience for your users. This will easily allow you to use the GPS positioning or you can cache content on your phone. A key problem with the internet connection on the phone is that the internet connection can be flaky. So you have to design for this. You took the right approach already: using the direct MySQL C-API to connect directly to the database server would not work that well, because this protocol is not stateless. You have to first login to the server and then you can send your SQL queries.
By using your API which is hopefully stateless, maybe even a RESTful API, then you can take some nice shortcuts for your native iPhone app. You could then use the RestKit library to easily convert your JSON answers from the server into objects, do caching and other nice features.
Write a web app
The second possibility would be to build a nice web app using state-of-the-art HTML5 technologies. The great thing about that is that you then would write an Android app as well as both mobile devices use a webkit browser. Well it is not exactly the case as there are different versions of Android out there with different screen sizes, but in general this assumption holds. Take a look at Google's web app for Google Calendar for example, I think it is a good compromise. You can also get a home screen icon for this and you will have no app approval process and can update anytime. Using HTML5 offline storage gives you some degree of freedom.
Using Phonegap
The option of writing the app in PhoneGap or some other HTML wrapper framework which will generate Objective-C code is a possible one, but in my opinion this is not really a good option. The reason is that you are working on some kind of intermediate layer and if anything goes wrong or you encounter bugs you will have to dive down to objective-c anyways. The other problem is concerning updates of iOS. It can break some dependencies and then you have to wait until your intermediate gets updated to use the new features.
Phonegap would be a good idea to develop this app. Phonegap although supports client side script only - which means you cannot embed php in its code. However you can easily create AJAX calls in your script that get and send data from your already developed php app/api.
Phonegap also supports GPS and data storage options where you can store the data locally and sync later when internet is available.
For reverse sync (server to client), you would have two options.
1. Create a javascript to make frequent ajax calls to check for updates.
2. Use Push Notifications (Here a tutorial for iOS APNs and Phonegap integration) - http://devgirl.org/2012/10/19/tutorial-apple-push-notifications-with-phonegap-part-1/
Using phonegap depends on one's preference. On the positive side, you save on time/cost as same code is used for all platforms. On the negative side, it has a slight lag when changing pages causing it to look like a website, but you can avoid that by using something like jquery mobile to prefetch all pages and then animate them back and forth. This will also help in uploading data in a separate independent thread while the user would be free to roam around the app.
Hope that helps.
Simply put, the best way to go is for you to use a php web service with phone gap.
You can also go through android using PHP and android. This is a very good and simple way to go. Try the tutorial here
You may tray Xamarin (part of .Net) with the free version of Visual Studio Community and then interact with your PHP web-app. You can then compile the native Xamarin app (written in C#) to Android and iOS.

Which is the best feasible solution for sharing the data from the database?

here is my scenario, i am building a web application using PHP and MySQL. basically it is a real estate application. where i would like to share the data among several other platforms and devices, here is i what i intend to do
a) building the web app to be used with the browser using PHP, MySQL, and AJAX. (this will be my server)
b) extend the support and build a desktop application using POKKI.
c) extend the support and build an application for Androids and iOS devices.
d) all data transaction for the app should take place from the web server.
e) basically it will be server client application . where the server will be my web server and the clients will be iOS app, Android App Pokki etc.
i am not a hardcore programmer, although it has been more then 1 year since i started using PHP, and i do understand it to my use. i would like to know the best feasible solution on how to share the data among the different clients(POKKI, iOS App, Android App).
i would like to know.
a) do i have to connect to database directly from the client and access the data? is it possible? is it bad if i go this way?
b) do i have to create a public class with api sign up process? what would be the real scenario if i would like it to make it cross platform.
A Humble request to all of you to guide me on how does this things works. any articles, resources, links that can prove useful to me will also be appreciated.
thank you.
I think you should create an API which allows you to access the database strictly as you want it. Look at the twitter API for example and see how it allows third parties to access their data using simple requests.
So your site uses the DB directly where as all other applications you want to make will use the API ( which runs on ur web server)
This would allow you with the flexibility to have control who gets access and who doesnt ( only your own apps or even third parties etc etc) and allows you to build kick-ass applications without putting your actual database at risk.
Hope this helps!
1 - you should not allow client to access data directly - bad.
2 - sign up are easy with open id, let google or any other openid provider handle authentication, you deal with your own clean code without worrying about auth.
http://code.google.com/apis/accounts/docs/OpenID.html
You can create xml api and share the data from your server.
On different type of client you can eaisly parse the xml data and process it or show it.
In xml API if you want the restrict access then your can provide the restriction.
Please let me know if you have any issue
Thanks and Regards,
Ankur K Singh
take a look into getfrapi.com for building API.

What are my options for creating an iPhone app from an existing PHP website?

I have an existing PHP/MySQL website that relies hugely on form POSTs for things like signing up, logging in, searching etc. I now need to create a native iPhone app for it. The business requires a native app for marketing reasons, I can't get away with a mobile optimized website.
I'm looking for suggestions from someone who has already done this - how did you rewire your website to POST/GET data from the iPhone app? I'm guessing I'll have to send/receive data as XML, which is then parsed by the server and client. Is there anything simpler or any framework that can make this easier?
Thanks!
If you don't have some sort of webservices or API to connect through for the website I would make that my first priority. While you can scrape HTML and send POST requests, it can get quite messy FAST. I've created iPhone apps which talk with webservices through SOAP requests, and have built an iPhone interface to a site, which wasn't pretty. It is very doable, but it is also very frustrating if anything changes on the webpage.
If you are looking for a decent library to help you get started with POSTing against forms check out the ASIHTTPRequest library at http://allseeing-i.com/ASIHTTPRequest/. If you look at the site there is a 'How to Use It' page with 'Sending Data with POST or PUT Requests'. Otherwise you could just use NSURLRequest and NSURLConnection and handle everything yourself.
It depends a lot on what you are presenting. You may be able to put a lot of your php heavy interfaces into web pages. The web pages and all related resources would be local to, and formatted for the iPhone. You can look at PhoneGap for examples of how to host local web pages and communicate with the host application.
I have been writing an eBook reader. About half of the user interface is done through local html files. In my case there is no network access, but WebKit is the easiest way to style text.
As long as your application does not look like a web page, it is fine if it is a web page. That may simplify big chunks of server interaction, especially things like login that only happen once or rarely.
Jonathan,
I would recommend taking a look at the Apple provided SeismicXML sample app. It uses the NSXMLParser to parse XML in a asynchronous fashion which will be huge for your app. It also shows how to use a NSURLConnection to make the request off of the web. You can use the NSURLConnection (which is also asynchronous) for POST/GET requests.
As mentioned in another answer, the ASIHTTPRequest library from allseeing-i.com is an excellent library but all of the features you want can be done using the built in Apple APIs if needed for your business requirements.
Hope this helps!

Categories