<div align="center">

# Bandwidth SIP Call registration

<a href="http://dev.bandwidth.com"><img src="https://s3.amazonaws.com/bwdemos/BW_Voice.png"/></a>
</div>

This application implements 2 way SIP-PSTN call flow
(using PHP catapult)

What you will need:

1. A Bandwidth Catapult account
2. SIP domains enabled on your account

Steps:

This application on success will create a user, domain and endpoint. Afterwards
listen to incoming and outgoing calls, using AnswerCallEvent and IncomingCallEvent,
when the calls are both found it will bridge into one call

Instructions / Howto:

Setting It Up:
----------------------------------------------------------------

To set the SIP call processor up, you will need to:

git clone  https://github.com/BandwidthExamples/php-voice-reference-app.git

update credentials.json with your own Bandwidth User Id, Token API Key and secret,
found in your catapult account settings:

Next:

check its running properly via:

php ./start.php

if all is well you should get:

"Thanks you can use the SIP Call Processing application"

Deploying
==============================================================

Once you've inputted your credentials, you can deploy the application,
below are some instructions

Heroku 
---------------------------------------------------------------

you can deploy this on heroku using the attached procfile,

commands:

  heroku create "my-sip-application"
  
  {add and commit}
  git push heroku master

Your application should now be viewable as my-sip-applicaiton.herokuapp.com


How to use
-----------------------------------------------------------------

Before using you will need to create a user, which can be done as follows:
  
  
curl -H "Content-Type: application/json" -d '{"userName": "aUsername", "password": "aPassword" }' http://{server_url}/users  

if all goes well you will receive a json response with your
newly created user


Using this application can be done two ways:
  
Inbound:
initiate a call to your Catapult number using an outside PSTN number
Outbound:
initiate a call using your SIP endpoint to an outside PSTN number


Other Notes
----------------------------------------------------------------
- username can be created once, subsequent requests with the same username and different
password will result in an error

- this application will create an application for each user under the namespace,
"SIP Client Application [username]" 

- this application will only use one domain