SIP subscription in PHP - php

I have several Snom VoIP phones in the office running off a virtual phone system in London somewhere.
I've written a small PHP app that lets me control the phone remotely - all it does in the background is cURL into my handset's web interface and control it that way.
However now I'd like my PHP app to know what other phones on the system are available/busy. I think the phone handsets do this by way of a SIP subscription with the virtual phone system, whereby my handset subscribes to feeds from all other handsets on the system and can then light/extinguish the busy lamp.
Am I going about this the right way? Is there any way I can have a PHP script subscribe to those notifications?
Many thanks in advance

This is not likely, but really depends on what you mean by a "PHP app". If it's a standard web-based application, you can't do anything about it. SIP communication is done over UDP sockets and requires you to listen all the time for responses.
If you mean an actual application, running all the time, then you need to implement the SUBSCRIBE/NOTIFY part of SIP spec and it is of course possible.
If you want to pull the statuses of other phones into your web application, I'd recommend setting up a server which will handle the standard SIP communication and subscribe to the phone's presence, then update the information in a local database. In the web app you can simply read the current status from the database and present it to the user.

Related

How to implement file sharing for mobile app over wireless network

I’m developing an app using Adobe Air. I want my users to be able to transfer files from a computer into the internal storage of the mobile app, but over a wireless router.
Question:
How to operate like a web server using my AIR app (turn the current smartphone into a web server)? I want run server-side scripts like PHP from device.
When the smart phone and the desktop (Mac/PC) are connected to the same wi-fi network, each one has an IP address like 192.168.1.xxx. Using the app, a PHP script will handle the file upload operation.
I am open to other (more correct or efficient) methods about transferring files between two devices, since the PHP way might be only solving an X/Y problem.
You could leverage the Adobe Cirrus technology (and you won't need any PHP).
Using Cirrus, you can create the functionality that you describe even if the devices are not on the same WiFi network (having in mind both the PC and the mobile device are running AIR applications). AIR is needed on the PC side in order to be able to access the files without user intervention. You won't enter the IP in order to link the PC app with the mobile app, although you'll need to provide the address received from the Cirrus service.
It is not trivial to write and test the apps, but they're definitely doable.
At the link above you should find all the info and resources in order to get started including how to get a developer key, an overview of RTMFP Groups and a sample app.

whats the best way to implement real time push messages with apache, php and mysql only?

i'm trying to implement a chat application for android (where users can communicate people who are in same location). i'm thinking it of an facebook messenger with Geo specific oriented. i came across to terms like repeated pull, comet, bosh, websockects, socket programming, xmpp(which requires xmpp capable server like openfire) etc to do this. But my resources are fixed like apache, php (codeignter) and MySql only. I need to find the efficient to way to do this. Guys i need this. Please help me.
Thank you,
abbiya
The preferred approach on Android is Google Cloud Messaging.
Google Cloud Messaging for Android (GCM) is a service that allows you
to send data from your server to your users' Android-powered device.
This could be a lightweight message telling your app there is new data
to be fetched from the server (for instance, a movie uploaded by a
friend), or it could be a message containing up to 4kb of payload data
(so apps like instant messaging can consume the message directly).
The GCM service handles all aspects of queueing of messages and
delivery to the target Android application running on the target
device. GCM is completely free no matter how big your messaging needs
are, and there are no quotas.
Essentially, it works like this: Your server talks to Google, and Google pushes the message in real-time (or nearly so, as long as the device is powered on and connected to the Internet) to the Android device(s). There's a registration process that happens on the Android device the first time the app is installed (and at future points to revalidate the registration). In your Android app, it's your responsibility to send this registration ID to your server so you can store it for future use. Your server uses this registration ID when it wants to push a message to that device.
The communication protocol between your server and Google is JSON over HTTPS. Your server can use any languages/technologies, as long as it can communicate with Google's servers. A PHP/MySQL application can definitely meet the basic requirements for the service:
Before you can write client Android applications that use the GCM
feature, you must have an application server that meets the following
criteria:
Able to communicate with your client.
Able to fire off HTTPS requests to the GCM server.
Able to handle requests and resend then as needed, using exponential back-off.
Able to store the API key and client registration IDs.
On the client side, the Android device must be running API version 8 (Android 2.2) or later. Of course, it's also your Android app's responsibility to process incoming messages (using a BroadcastReceiver, as the Android system sends an Intent to your receiver whenever a message arrives), which allows you to handle messages however you want.

PHP to Quickbooks - how do I connect the two if she's running on a desktop?

I'm tasked with coming up with an e-commerce solution for a small, local business. My client uses Intuit/Quickbooks point of sale software. I've just discovered that Intuit has a series of PHP 5+ classes that allow interoperability (link for anyone else that may stumble on this: https://code.intuit.com/sf/sfmain/do/viewProject/projects.php_devkit).
The website will be hosted on shared hosting, so the two systems are split quite literally. Her desktop does have internet access.
So, my questions:
Is there a way for me to connect to her desktop via curl?
If so, is there a way for me to do it securely if I can't create a VPN on my host?
Now that I think about it, is there a VPN service I could use?
Any other security things I should be aware of?
Payment processing will be handled through Stripe (http://www.stripe.com). This is really just for inventory/order synching.
Your best bet is the QuickBooks Web Connector, along with that set of PHP classes you mentioned. See my specific comments below:
I've just discovered that Intuit has a series of PHP 5+ classes that allow interoperability (link for anyone else that may stumble on this: https://code.intuit.com/sf/sfmain/do/viewProject/projects.php_devkit).
It's worth noting that that library is NOT developed by Intuit (disclaimer - I'm the developer of that library). Intuit hosts our Subversion repository, but we're a separate company, and Intuit does not contribute to the actual PHP code. Intuit provides a Windows COM-based API only, we provide the actual PHP components so you can talk to QuickBooks from a remote server via the Web Connector, without the need to muck with COM.
We have a ton of information on our QuickBooks integration wiki which might be helpful - specifically the QuickBooks integration with PHP section and this overview of the QuickBooks Web Connector.
Consider grabbing the latest nightly build from the link you posted, and taking a look at this file:
* docs/example_web_connector_point_of_sale.php
It illustrates exchanging data between PHP and QuickBooks Point of Sale.
The website will be hosted on shared hosting, so the two systems are
split quite literally. Her desktop does have internet access.
This ^^^ is just fine, and a typical scenario. It's exactly what the Web Connector was designed for. The Web Connector essentially acts as a "dumb proxy" between a PHP SOAP service, and QuickBooks itself - it relays messages from your PHP app, over HTTP(S), to QuickBooks.
Is there a way for me to connect to her desktop via curl?
Not with Curl, no (though you could build one... but why reinvent the wheel?). The Web Connector is SOAP based, but your PHP components will be the SOAP server half, not the SOAP client half.
If so, is there a way for me to do it securely if I can't create a VPN on my host?
The Web Connector can use SSL via HTTPS to keep the data secure while in transit across the net.
Now that I think about it, is there a VPN service I could use?
Just buy an SSL certificate, it's easier. :-)
Any other security things I should be aware of?
Not beyond the typical web application security guidelines that you could find elsewhere on Stackoverflow.
If you're going to sync to a system like Quickbooks, don't do it real-time, do it in a batch process that is resilient to things like her desktop being turned off, the crappy office internet (compared to a datacenter) being slow or down, etc.
This ^^^ is great advice, and is exactly how the Web Connector works.
If you need real-time, Quickbooks running on a desktop is NOT the way to go.
In fact, if you need real-time, QuickBooks period is not the way to go. QuickBooks is a great small to medium business accounting software... but is slow and not reliable enough for consistent real-time communication. With that said... what you're talking about does not require real-time communication, so this shouldn't bother you.
Batching the orders isn't a problem, but how would I make even a batch process resilient?
The PHP code uses a queue with a status, so you can track what got processed, what didn't, what you got back from QuickBooks as a response ("Added a customer successfully!" vs. "Ooops, failed to add a customer because ..."), what error messages QuickBooks threw, etc. and then react appropriately with your code, or manually.
You won't need cron - the Web Connector can be scheduled to run, and it'll relay all errors and a ton of other information back to you so that you can handle errors, send out warnings, build reports to show to people about what failed/succeeded, etc.

best practice to push to GCM/APN from php

I am currently building a SNS for both web and iphone/android applications.
When an user writes on the wall or leaves a message, the server needs to push notifications to all related users. Users who are logged in on PC will receive it via Socket.io and those who are logged in on iPhone or android apps will get it via GCM/APN.
What is the best way to send push notification(GET) to all these users from a php web server?
cURL seems to do the right work but is extremely slow on my server.
The web server will need to send notifications to at least 3 different servers at once at unnoticeable speed.
Any suggestions?
I'm in the process of building such an application and I have to be honest and advise you to use Zend Framework. There is also a lot of database planning to be done as read/writes to and from a database will be high. Specifically use Zend_Mobile or visit my blog for the gcm solution http://www.rogerethomas.com
Ideally you should run a cluster of servers processing messages and queues. Push messaging can get out of hand quickly and taking the time to plan it properly will pay off I promise you.

PHP web application + TAPI / VOIP telephone calls?

A client wants to use our (ERP) web application as some kind of incoming and outgoing calling software. He needs phonenumer recognition and to be able to dial a number by clicking with the mouse and then pick up his phone.
Somehow a TAPI or VOIP connection must be made on the clients computer, I think... for this I could create a small listener/dialer program (not in PHP, but in Delphi for example) that is installed on each client,but how would I let this communicate with the browser / web server?
Another way could be by installing our web application on the server of the client itself, which has a direct link to the telephone software server.
Has anybody ever done something like this in PHP ?
Any suggestions?
Is your ERP software written in php? You may want to integrate with Asterisk (and open source pbx) (and by extension FreePBX if your in php anyway)
I came across this site www.tropo.com which has an API that adds Voice and SMS support to PHP and other languages.

Categories