A sample PHP application that demonstrates a server capable creating a simple gather IVR using Bandwidth's Voice API .
To start the PHP server you will need to run the command php -S localhost:5000 -t public.
In order to use the Bandwidth API users need to set up the appropriate application at the Bandwidth Dashboard and create API credentials.
To create an application log into the Bandwidth Dashboard and navigate to the Applications tab. Fill out the New Application form selecting the service (Messaging or Voice) that the application will be used for. All Bandwidth services require publicly accessible Callback URLs, for more information on how to set one up see Callback URLs.
For more information about API credentials see here
The sample app uses the below environmental variables.
BW_ACCOUNT_ID # Your Bandwidth Account Id
BW_USERNAME # Your Bandwidth API Username
BW_PASSWORD # Your Bandwidth API Password
BW_VOICE_APPLICATION_ID # Your Voice Application Id created in the dashboard
BASE_CALLBACK_URL # Your public base urlFor a detailed introduction to Bandwidth Callbacks see https://dev.bandwidth.com/guides/callbacks/callbacks.html
Below are the callback paths:
/outboundCall/voiceCallback/gatherCallback
A simple way to set up a local callback URL for testing is to use the free tool ngrok.
After you have downloaded and installed ngrok run the following command to open a public tunnel to your port ($LOCAL_PORT)
ngrok http $LOCAL_PORTYou can view your public URL at http://127.0.0.1:{LOCAL_PORT} after ngrok is running. You can also view the status of the tunnel and requests/responses here.
