I have a USB GSM device which I use for Internet connection as well as for Sending SMS through the software provided by the device itself. I would like to know if is it possible to read this device from USB port using PHP server side script ?
If it is possible, how we can do it & process some actions on it like Send SMS or receive SMS ?
Currently I am using Wamp on my Windows Machine. I would also like to do this on Linux machine too but that is in the very later stage so that is not part of this question at the moment.
Thanks in advance.
There are several libraries and tutorials about how to control serial ports with PHP.
Example: https://gist.github.com/51342
Article about this http://www.communitymx.com/content/article.cfm?cid=8658A
An article about exactly what you need is here (thanks to Mathew Hall)
Related
This is something unusual I am doing other than coding. So My question is bit tricky and for those who have some knowledge of hardware programming I think so.
So all I am doing is, I bought one web Relay device from Hw group and it's called IP Relay ER02b. Which has two inputs 1 & 2 and that I am controlling through command prompt like on/off using web relay device IP address.
However, I have one more pin-pad device which is connected to web Relay into port called RS232. So there is no direct connection to my laptop with pin-pad device.
So the question is, how I can read incoming pin-pad numbers using IP address of web relay using command prompt as I searched a lot and couldn't find the way to do this using command prompt or PHP as PHP is also fine.
Any help on this will be appreciate and if need any further information then please let me know and I'll more than happy to provide.
Thank you guys in advanced
I have a number of phones on my network and I would like to be able to send a number to one based on extension for it to dial.
I have looked into TAPI and the PHP COM events but I don't understand it all that well and how to apply it to my setup.
Does anyone have any experience with using PHP to send commands to an IP phone on their network?
If these are Cisco IP Phones you can look at using the Ip Phone Services API: http://developer.cisco.com/web/ipps
Look specifically at "Dial" Telephony URI in the Application Development Notes
Each IP phone has a web server on it, you can use standard http(s) posts to send XML commands to the phone. You can completely control the phone in this manner.
You have to understand that client-server communication is a bit unidirectional. From iPhone to server you can easily send messages (and get responses), but to send a message from server to iPhone you have to implement socket connection between them, so the iPhone will always "listen" to what the server is "saying". Also, push notifications are a way to send messages from server to device, but it's not your case, I guess.
In one of my projects a PHP server is successfully serving a php client via sockets but when I try an iPhone client using the NSStreams to this PHP server the client gets connected but if I send a string from the client to server, the xcode comes up with error message that connection is broken.
If I use the same iPhone client to connect to a server running on Python, it establishes the connection and strings are being read/written without any problem.
Can someone understand this please? If some sample or tutorial on PHP / iOS applications on sockets then I will be obliged.
hi you can use WebSocketServer located on http://code.google.com/p/phpwebsocket/ and on Iphone clien http://www.raywenderlich.com/3932/how-to-create-a-socket-based-iphone-app-and-servert
i cant repost my code here, because SO considers it spamming to repeat your answer.
check out this sample code and tutorial link. works like a charm and is really simple to implement, less than 3 minutes and you are up and going (IF you have a socket server ready).
as a general rule, php might not be the best solution for a socket server. i like working with c++ or python better. just holler if you need some sample code for a socket server using c++.
also, it is VERY VERY VERY important to check if your server has open ports. unless you are using your own server, chances are that your hosting package does NOT open ports. a virtual private server is necessary for that. at this time, i strongly recommend amazon's AWS EC2 servers.
in case you have difficulties with it, i can give you a couple of nudges in the right direction.
I have searched on Google and found that I have to use AT commands to send SMS here is the link,
http://gonzalo123.wordpress.com/2011/03/21/howto-sendread-smss-using-a-gsm-modem-at-commands-and-php/
But in this tutorial he is using serial interfaced GSM modem, is it possible to send SMS via USB interfaced GMS modem. Please guide me.
A USB interfaced GSM modem will be presenting a USB serial interface, usually / hopefully conforming to the USB CDC specification. In other words you can treat it as a virtual COM port and the tutorial you linked to will still be relevant for you.
In Unix systems you can read/write from USB and Serial port reading data from /dev/ttyS0 or /dev/ttyUSB0. You also can use a usb/serial converter. They are cheap devices. But my experience with those usb converters is very bad. Because of that I prefer to use serial/ethernet convertes. They also allow me to place the serial device in any place and not necesary close to the server. OK maybe with a GSM device is not a problem. We can place it wherever we want, but if we are using the same technique to read/write from another device (like sensors, scales, ...), this may be a problem.
Please what is the AT commands in PHP compatible with Huawei USB Modem ?
i need to use these commands in script then i can send sms using the Huawei USB Modem.
thanks
The first thing you need to do is to open up the serial port with PHP. There is a class for doing this: http://code.google.com/p/php-serial/
Once open, it is as simple as this:
$serial->sendMessage("AT+CMGS=\"+1231231234\"\nHello");
Obviously, the AT commands can vary from device to device, so you will need to find out the commands for your specific device.
A saner approach would be to delegate SMS management to a specialized software, because in my experience there's more to do to manage SMS sends than just throwing a couple of bytes to a modem
network availability checks and the corresponding retries to optimize your delivery rate
capability to receive SMS'es
multipart messages
routing
...
I suggest the most excellent SMSTools it's a server software compatible with Linux and Windows, it talks with your application via regular ASCII files in specific directories (in, out, failed, ...) and has a host of other advanced functions.
To send a basic sms with default options you just have to create a text file like this one
To: 155512345
Hello, this is the text of the SMS
in the out-spool directory, on Linux that's /var/spool/sms/outgoing unless you reconfigure that path.
Best of all it's free and open source.