Sending commands to an IP phone on the network using PHP - php

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.

Related

How to receive GPS data from device with PHP?

I have a car GPS device, the only thing I can change is the IP-address.
Is it possible to have shared hosting with a dedicated IP-address (that part is possible) and then to have a PHP script that picks up the data that is being send?
So what is in my mind:
GPS device send gps data to IP-address.
That IP-address has a PHP script that picks up the data and use it.
As requested a little bit more detailed.
There is a question that is exactly the same but don't have an answer: how-to-get-data-from-gps-and-send-to-server-and-how-save-to-database
It is a Chinese car GPS device with a standard IP address. So it sends data to that IP address. Then they give us a website where we can login with the product code and we can see the GPS location.
It is possible to change the IP address in this device. I have found shared hosting with a dedicated IP address, but that means the IP address just replaces the URL so it works just as an URL, so it is not that I can change the server and install something like openGTS.
But I have no idea what kind of data (I don't think it is just GET or POST data) this device is sending. So I am wondering if the GPS is sending the data to an IP address whether I have to do something special with java on that server or I am able to use a PHP script to pickup what the GPS device is sending? Once I get the data I know what to do with it. All I need is the data to be picked up by a PHP script.
There is not a shortcut as I was hoping. For a gps tracker device that sends TCP/UDP data to an ip address and port we really need a server. There will be no POST/GET data. The server will receive data through a port that needs to be decoded. But it was not as complicated as I thought. Even without any knowledge of Java I was able to install a software and manipulate it to my liking.
What I did:
Got a windows server (2012) hosting (6 months for free) so I could
try it out.
Downloaded opengts and followed their instruction manual exactly. And did not find it hard at all. It worked without having much headache
Once I got to the part where everything was working I could play around with the device and it was working fine. Ofcourse we need to know the protocol (the data) that the device is sending and decode so it can be saved in the database.
you need this:
The phone(Number) (with GPS).
A SmartPhone( Androir and develop your own APP) - (Like a Sub-Server).
A (Home Server) or (WebServer) with MySQL(Data Base).
A Script with PHP in your Server or WebPage(Point 3).
So:
The (Phone Number with GPS) just wait for a call or something to send the "Data".
(The SmartPhone) get the data from (The Phone Number with GPS).
Read the Message Board ONLY from your (Phone Number with GPS) with (your Own APP Android) AND Process the "Data" with (your Own Android APP).
Get the "String" of (Lat) and (Lon) Coordinates Or ALL your need from the (Message Board) and SEND to your (PHP Script) using HTTP request to your (Home Server or WebPage) From your (SmartPhone) Using your (Own Android APP).
Work with your (PHP Script) and save in your (MySQL Data Base).
... you can do everything now with the "Data", like show with other php script and google maps api, or use for a desktop application on java, or visual basic, etc..etc..., or all you wish.
Note:
*Not use your (SmartPhone) for nothing, only for prossesing "Data" of ALL (Phone Numbers) your want Using your (Own Android APP) Reading the Message Board with Code, so your (SmartPhone) now is like a "Mini Server" and only works as an intermediary between your (Phone Number with GPS) and your (PHP Script) in your (Home Server or WebPage) with (MySQL Data Base).
You need to use Database, create php script (POST query) and update query into database when GPS position change, than you can have access to this position from database with another php script (GET and return json object)
If you have a shared hosting, you'll only have the 80 port open. So in your device, you will need to make HTTP requests to that IP on port 80.
In order to make a correct HTTP request, read the RFC2616 (http://www.w3.org/Protocols/rfc2616/rfc2616.html) to get started with HTTP protocol.
At minimum, you will need to provide a hostname and URI in your HTTP request.
On that URI, your PHP script will be able to read data and do something with it.

Making the web server as a relay between two sides

I want to control a robot from the web, the robot is connected to Android device. The operation will be as the following :
a web application written using JavaScript and HTML runs on desktop computer which takes the keyboard input from the user and send them to the android device connected to the robot.
the android device receive the commands and then send them to Arduino board which used to control the robot.
But how should I deliver the data to the Android device which doesn't has a static IP address?
I have two approaches to solve that :
the JavaScript application sends the keyboard input to a web server runs PHP and MySQL , then the php application store the data on the MySQL database. An application runs on Android connected to that web server and extract the data from the MySQL database.
the JavaScript sends the data to the web server. The android application connected to the web server receives the data directly so the web server is just used as a relay.
The first approach is easy to do but its slow , so my question is...
How to implement the second approach and which web technologies should I use to implement it? And how to make the web server works as relay between two sides?
PS : I am planning to use 000webhost.com as web server. so I will not use my own server
You can either have your Android application poll the webserver for outstanding commands. This is a little inefficient in terms of data usage, but if you're on an unlimited 3G plan / wi-fi, you could live with it. It will be very easy to implement.
Alternatively, set up a TCP server on your server, and have your Android application open a socket connection with the server. This way, your web application can send commands to the server which will immediately stream them to the Android device. It will be slightly harder to implement, but will be more efficient and robust if done right.
PS - Most shared servers don't allow you to open a TCP server on your host so you might be forced to go with the first option.
PPS - I wasn't aware of Google Cloud Messaging. It seems to be a good solution for you what you're attempting to achieve. You should have a look into it.

J2ME PHP Push Notification

I want to work on a project which has to do with the server sending notification to the client. The client side is a j2me application and the server side script will be implemented using PHP.
I have found out i can use the push registry API in midp 2.0 for push notifications, but i don't know how to implement this such that a socket connection will be created to the server such that notification can be sent to the client via the socket connection. The notification will then trigger the start of the midlet.
How can i use the push API to create a socket connection between client and server and have notifications sent to the client?
Complete answer is here
In short, there are two ways you might want to do it
Launch the application whenever you receive this "Push SMS"
Launch the application just the next time you receive this 'Push SMS"
For situation (1), you will need to specify this in JAD file. If you do this, the application manager will take necessary steps to launch your application the next time SMS is received.
For situation (2), you will need to write code:
PushRegistry.registerConnection("sms://<port number>","Midlet-Class","*");
The above note of mine would address the issue of launching the application upon incoming SMS. After you launch you can connect to your server and post data or retrieve data. This is a practical way of implementing push for J2ME platform.
But you seem to be wanting to launch the application on incoming network connection; this means you are creating a server socket on the phone and server is trying to establish the connection to the phone applications. I did work in such a situation where the phones were deployed on Motorola's iDen network (pre-2005 era). On such networks, it is possible to assign an IP address to the phone which makes the Push upon incoming network connection feasible. But that's past, on none of the GSM/CDMA networks, atleast at consumer's end, this cannot be supported. Hope it answers your question.
You need to do two things, One you need to listen one port number on the J2ME side for the incoming sms. Next you need to attach one GMS Modem to your computer system, Now send sms using this Modem on a particular port to the mobile you are listening. You can use AT Commands to send SMS.
Please visit this Nokia Link.

Android - web server connectivity and authentification

I need my app to be able communicate with a web server. The problem is I want web server to respond only to requests made from real android phones.
So, is there any way to make sure, that server works only with real phones? It should reject anything else to prevent spamming database from computers or emulators. Is it possible without sms verification?
And how good is socket support in Android? If I want to write server software in C will it be able to communicate with Android based devices? Or I have to use php, or something like that?
Maybe OpenSSL, but still I'm not sure.
Thanks in advance!
PS: sorry for my English
There is no real way for a web server to distinguish a real mobile device from a device that poses as one. Generally, the user-agent header is used to determine the type of client device, the value of which can be overwritten by any client.

What do I need to send text messages with Kannel?

I want to be able to send text messages from Linux with PHP. I've read about and installed Kannel, a free SMS gateway. When I try to use the HTTP interface, it won't send a message. Do I need something else to send text messages via kannel, like a modem?
Yes, you need a GSM modem and a SIM card from your local mobile network provider.
To setup your GSM modem, you can auto-detect its settings using wvdialconf. The output contains pertinent information such as Baud rate, which serial port is used, and the modem's initialization string.
To test that your modem works properly, you can use minicom. Minicom acts as a terminal to any serial device (in this case, a GSM modem) and, with it, you can send AT commands to your modem.
I dont know if this is a solution, but Clickatell provides a very easy to use HTML api for sending sms messages anywhere in the world. I'v been using them for several years. You only pay for the sms messages you send.

Categories