A simple PHP sample application demonstrating how to bridge two live calls using the Bandwidth V2 Voice API.
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
BW_MESSAGING_APPLICATION_ID # Your Messaging Application Id created in the dashboard
BASE_CALLBACK_URL # Your public base url
USER_NUMBER # The number dialed out to when an inbound call is received on your Bandwidth numberFor a detailed introduction to Bandwidth Callbacks see https://dev.bandwidth.com/guides/callbacks/callbacks.html
Below are the callback paths:
/callbacks/inboundCall/callbacks/outboundCall
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.
