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.
Related
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".
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 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.
In my website, I have to make a chat system similar to Gmail so registered users can chat with their group. I have no idea about how I will do this. Can anyone provide me with an idea of how to implement this or any useful links? I have to do it using Zend Framework.
Since you are looking to work this out using Zend framework, have a look at Jaxl library (Jabber XMPP Client/Component Library). The library can be integrated with any existing website/framework and also contains several examples for browser based chat applications.
Actually there are two parts for chatting:
A long running request that streams massges from the server to the client
Ajax messages from the client to the server that sends one message to the server
For the second, any ajax framework will do it. For the first you might have a look at Comet to get the idea for this. But you should be aware that html isn't ment to be a chatting protocol. If you don't pay attention such stuff can easily kill your server.
I am wondering how to integrate jabber instead of using my AJAX polling script. I chanced upon the following: http://code.google.com/p/xmpphp/
It gives me access to a jabber server, but does not tell me how to exactly go about it. I mean for example
$payloads = $conn->processUntil(array('message', 'presence', 'end_stream', 'session_start'));
Are there a fixed set of commands that I can use? Is there some site which explains the jabber workflow in very simple terms?
Thank you very much for your time.
I've been wondering about technologies to play around with XMPP, been looking at:
Strophe
BOSH
Examples of this technology can be seen at:
drop.io
Chesspark
These two doc pages seem to be fairly readable:
Core
Instant Messaging and Presence
Also, you might already be heavily invested into xmpphp, but if not, you may want to take a look at Phurple. It gives you access to the libpurple library (the code-base for Pidgin) from PHP.
From the project page:
This libpurple PHP binding, which
defines a set of internal classes,
gives a possibility to use aol and icq
(oscar), yahoo, msn, jabber, irc and
much more protocols directly from PHP.
Write your own IM chat client in PHP,
as simply as PHP enables it.