-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #170 from Nexmo/application-v2
Application v2
- Loading branch information
Showing
20 changed files
with
1,074 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
require_once '../vendor/autoload.php'; | ||
|
||
$client = new Nexmo\Client(new Nexmo\Client\Credentials\Basic(API_KEY, API_SECRET)); | ||
|
||
$a = new Nexmo\Application\Application; | ||
|
||
$a->setName('PHP Client Example'); | ||
$a->getVoiceConfig()->setWebhook('answer_url', 'https://example.com/answer', 'GET'); | ||
$a->getVoiceConfig()->setWebhook('event_url', 'https://example.com/event', 'POST'); | ||
$a->getMessagesConfig()->setWebhook('status_url', 'https://example.com/status', 'POST'); | ||
$a->getMessagesConfig()->setWebhook('inbound_url', 'https://example.com/inbound', 'POST'); | ||
$a->getRtcConfig()->setWebhook('event_url', 'https://example.com/event', 'POST'); | ||
$a->getVbcConfig()->enable(); | ||
|
||
$r = $client->applications()->create($a); | ||
|
||
print_r($r); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
require_once '../vendor/autoload.php'; | ||
|
||
$client = new Nexmo\Client(new Nexmo\Client\Credentials\Basic(API_KEY, API_SECRET)); | ||
|
||
$a = $client->applications()->get(APPLICATION_ID); | ||
|
||
$client->applications()->delete($a); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
require_once '../vendor/autoload.php'; | ||
|
||
$client = new Nexmo\Client(new Nexmo\Client\Credentials\Basic(API_KEY, API_SECRET)); | ||
|
||
$a = $client->applications()->get(APPLICATION_ID); | ||
echo $a->getName().PHP_EOL; | ||
|
||
echo "\nPUBLIC KEY\n-----\n"; | ||
echo $a->getPublicKey(); | ||
|
||
echo "\nVOICE\n-----\n"; | ||
echo $a->getVoiceConfig()->getWebhook('answer_url').PHP_EOL; | ||
echo $a->getVoiceConfig()->getWebhook('event_url').PHP_EOL; | ||
|
||
echo "\nMessages\n-----\n"; | ||
echo $a->getMessagesConfig()->getWebhook('inbound_url').PHP_EOL; | ||
echo $a->getMessagesConfig()->getWebhook('status_url').PHP_EOL; | ||
|
||
echo "\nRTC\n-----\n"; | ||
echo $a->getRtcConfig()->getWebhook('event_url').PHP_EOL; | ||
|
||
echo "\nVBC\n-----\n"; | ||
echo $a->getVbcConfig()->isEnabled() ? 'Enabled' : 'Disabled'; | ||
echo "\n\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
require_once '../vendor/autoload.php'; | ||
|
||
$client = new Nexmo\Client(new Nexmo\Client\Credentials\Basic(API_KEY, API_SECRET)); | ||
|
||
foreach($client->applications() as $application){ | ||
echo $application->getName() .' - '.$application->getId() . PHP_EOL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
require_once '../vendor/autoload.php'; | ||
|
||
$keypair = new \Nexmo\Client\Credentials\Keypair( | ||
file_get_contents('/Users/michael/development/nexmo/empty-voice-project/private.key'), | ||
'75196d98-d3a0-476c-9fbc-7df9aa326aff' | ||
); | ||
|
||
$client = new \Nexmo\Client($keypair); | ||
|
||
use Nexmo\Call\Call; | ||
$call = new Call(); | ||
$call->setTo('447908249481') | ||
->setFrom('123456') | ||
->setNcco([ | ||
[ | ||
'action' => 'talk', | ||
'text' => 'This is a text to speech call from Nexmo' | ||
] | ||
]); | ||
|
||
$response = $client->calls()->create($call); | ||
|
||
echo $response->getId(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
require_once '../vendor/autoload.php'; | ||
|
||
$client = new Nexmo\Client(new Nexmo\Client\Credentials\Basic('7c9738e6', 'n3w-Api-key!')); | ||
|
||
$a = $client->applications()->get('a8f93ca3-2a6f-4722-a53e-b7cccabc0bb9'); | ||
|
||
$a->getVoiceConfig()->setWebhook('answer_url', 'https://example.com/answer', 'GET'); | ||
$a->getVoiceConfig()->setWebhook('event_url', 'https://example.com/event', 'POST'); | ||
$a->getMessagesConfig()->setWebhook('status_url', 'https://example.com/status', 'POST'); | ||
$a->getMessagesConfig()->setWebhook('inbound_url', 'https://example.com/inbound', 'POST'); | ||
$a->getRtcConfig()->setWebhook('event_url', 'https://example.com/event', 'POST'); | ||
$a->getVbcConfig()->disable(); | ||
|
||
$client->applications()->update($a); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.