i want to make messenging service in my site

December 9, 2008 12:34pm CST
hi...i want to make messaging services like g talk in my site with the help of PHp coding can any one help me or give me an idea about how to make it?... from where to start.. i am beginer in php
2 responses
• United States
10 Dec 08
Okay, I can't write the code for you (that would take days and days), but I can try to explain fully what you are going to need to do to attempt this project either by writing your own code or using a 3rd party chatbox. First of all I'm going to assume you only want text chat and not voice, similar to the chat in Gmail. While you could set up a voice system, it would require a Java or Flash applet which is beyond the scope of my knowledge (although there is definitely one out there by someone else you can add). Writing your own scripts in PHP gives you the advantage that you can control them, add user options, and fully integrate everything into your site. The disadvantages are obvious, though. You will need to know Javascript and PHP and you will combine them using a set of techniques called AJAX (Asynchronous Javascript and XML). It you have ever looked at a REALLY old chat script that didn't use this method, you will notice the page fully reloads every few seconds. This looks terrible to users of the modern web, so you have to use Javascript to transfer the chat data in between reloads. This is what AJAX does. There are two methods you can use for AJAX. The first, and the easiest to understand from my point of view, is to place a hidden (0x0) iframe in the page and use the Javascript innerHTML property to place a hidden form with your data in the iframe, reload it separately from the main page, and read its contents back to get a response from the server. You should know how forms work and how data gets transmitted to them and read by scripts. The second relies on a method called XMLHTTPRequest which requires that you build a full HTTP header (not as hard as it sounds, but more difficult than the iframe method), and use that. Both of these should work fine on modern browsers but for certain things you will have to write in 2 different approaches (IE and Firefox) to make them work for everyone. On the backend (server), you will be handling all these requests by instances of PHP scripts called by the Javascript code when it sends an HTTP request or relaods an iframe. This isn't much fun either, and can get damn confusing really fast becaause you have to deal with sessions, mySQL databases, and the like which I don't pretend to understand well enough right off the bat to explain them, but hopefully you do since you asked about PHP. The other route is to find a chat box flash app or something that you can plug into your pages. This probably wont' be as customizable as you want and may have adds in it, but it is easy and quick soultion that you will probably want to go for. Once your site becomes popular (best of luck with that) and you make money you can hire a freelance developer to do the dirty work of making a better chat system for you. Anyway hope I helped a bit, in any case I have rambled far longer than I ever did before on mylot, so nice topic!
1 person likes this
10 Dec 08
hi paint guru...your are such a genius.... i will follow wat ever your are saying.... thats very much informative.....i am goin to try each and every thing you say.. add me as your friend... thanks for my lotting
@runeman (35)
• India
10 Dec 08
Or if you want a more primitive chatbox, use the method which i did. What i did was i made an iframe in my index page which is linked to another page. The chat messages + the username of the guy posting it is stored in a txt file, which is opened and parsed from for displaying the messages and when someone types a message, the txt file is edited and his message is added. The page which displays the txt file is set to refresh every 5 seconds.