I have looked on here and anddev for a suitable response, but haven't found anything suitable.
Here is the question: My friend has an instant chat application with iPhone, and since I have some basic android experience he asked me to check out "porting" it to Android. So before I set up the UI, I decided to look into php which I don't have much experience with. I know the UI will need an array to call contacts, but I'm not sure about retrieving the information from the php.
How do I know if I can use his script or not? I haven't found any good tutorials about Android and Php - has anyone found one?
I might as well learn this stuff now because my next app will require an online database to be used in it - I know his has users and passwords, and he'd like to be able to send im's between iPhone and Android clients.
Thanks for any help you may provide!
EDIT:
Yes, this issue is more related to http requests from android to a remote server; I have changed the tags and subject accordingly, but would still appreciate a guide to android-friendly php writing. Thank you!
There really isn't Android-Friendly PHP but there is mobile friendly PHP. Basically, you need your PHP scripts to emit something that is easy to parse in an application (like XML or JSON) rather than the standard HTML. After that, all you need to do is figure out what the API should look like on the server side. That is, what functions does the server need to provide and how is it going to provide them. Are you going to use simple HTTP authentication or are you going to use something more complicated?
With regards to his chat application, I would imagine that if he already has an iPhone version, then you won't need to mess with the sever side at all. All you need to do is figure out what URLs and parameters to use for what operations. You also need to ask him what data format his server uses. If it's XML, you need to find an XML parser, if it's JSON then you need to find a JSON parser etc. (there are plenty of tutorials on how to do both in Android via Google). I would start by asking him, at a high-level, not with Objective-C specifics, how his chat application communicates with the sever. You can then use that to build your application to communicate in the same manner.
Related
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.
Can anyone recommend a tutorial or point me in the direction of some easily implemented .net or PHP code that i could use to setup a third party application server for C2DM.
I am a Front-End Developer with some PHP/.net experience, but very minimal Java experience, our app is setup with the required java code/classes and I have registered with C2DM, but i'm struggling with the application server part of the equation.
I would like to setup a server application that can handle form requests to send a message out to our app.
Any help or advice would be greatly appreciated!
The server part of C2DM is a piece of cake compare to the client (in my opinion). You can find below some tutorials about the server part :
One for JAVA very easy to understand even if your are not JAVA developper.
One for PHP and Zend framework.
A basic example for C# on stackoverflow
A common mistake to avoid if you want some performance : Don't connect for each message to send.
You just have to auth one time to the google server and then you can send multiple notification message.
Also don't forget that Google will periodically refresh the token in an Update-Client-Auth header. You should handle this header to keep your tokens up to date. Have look to this discussion about it
You may want to have a look at this post. It is a basic PHP implementation using curl.
I am building a server-side C2DM based on Drupal CMS.
While it is not 100% ready, if you want I can try and help you building it.
Using Drupal as the server-side, and its amazing modules such as Services and Rules, you can create a very interesting applications very easy, almost "out-of-the-box".
I've been tasked with creating an IM app for IOS. I currently have an XCode programmer creating the app itself and we have selected OpenFire for the XMPP server. The only issue is that I have never done anything closely resembling a chat program before and am having difficulty getting things rolling. I have installed OpenFire and have it working correctly and have the database setup. Now I have to figure out where to go from here. I have no idea how to make an XMPP request nor do I know how to write a client. I am a seasoned PHP vet and am using PHP to write an API for our chat app but I dont really know if I should try going the route where I use PHP to make XMPP requests or if the XCode programmer should do that. In any case I need to read up on how to make XMPP requests in general and then of course figure out how to do it in my language of choice. I am really hoping to stick to what I know with PHP. It seems most of the prefab XMPP clients are Java based which doesn't help me at all. Any help, advise, or reading material that anyone could help me out with would be great.
I don't see why you would need the extra PHP layer.
XMPP supports all the features (or most of them) you need for an IM.
You could just connect to XMPP from iOS, for example with this library.
But if you insist on a PHP layer, here are some XMPP libraries. Not just PHP, but lots of languages.
If you want to familiarize yourself with the XMPP protocols, look here. They are very well documented.
What is the best way to connect an android application and a php server using sockets? I am trying to implement a chat system between multiple clients, but I know that PHP does not allow multithreads.
Sorry for not giving enough information about what I intend to do. I basically want to create an app simmilar to google latitude, and I also want to implement a chat system between the users. I have aldready decided that I am going to use a MySQl DB and therfore a PHP server so the client communicates with the DB using JSON for data exchange. I am quite new to this and I don't know how the architecture Client-Server-Client communication should look like. I found out that the easiest way to do this is using HTTP requests, but I don't know how I should implement this.
I think you can use jabber protocol, install any xmpp server and you can connect to that from android, this is standard for chat applications
use xml-rpc base php webservices for chat server. your chat client will contact to chat server throught web services.
*I was going to make this a comment but I ran out of space, plus it does have some answer-y qualities to it.
This question does not contain nearly enough information for anyone to usefully help you. How do you think it should be done? You can't ask people to critique an idea when you haven't told them what your idea is.
PHP is the wrong language for this, because (as you rightly point out) it can't be multi-threaded - amongst a multitude of other reasons. I personally would recommend Node.js (or possibly Java), but that's just my preference.
If you still insist on using PHP, take a look at this. It might give you a point in the right direction for a non-blocking multi-IO setup such as this - but you're letting yourself into a whole world of unnecessary complication by doing this in PHP.
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!