bandwidth / sdk
Bandwidth's set of APIs
Installs: 552 121
Dependents: 1
Suggesters: 0
Security: 0
Stars: 15
Watchers: 38
Forks: 8
Open Issues: 2
Requires
- php: >=7.2.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- ext-simplexml: *
- apimatic/jsonmapper: ~1.3.0
- mashape/unirest-php: ~3.0.1
Requires (Dev)
- phpunit/phpunit: ^9
- dev-main
- v11.0.0
- v10.6.1
- v10.6.0
- v10.5.0
- v10.4.0
- v10.3.0
- v10.2.0
- v10.1.0
- v10.0.1
- v10.0.0
- v9.1.0
- v9.0.0
- v8.2.0
- v8.1.2
- v8.1.1
- v8.1.0
- v8.0.1
- v8.0.0
- v7.0.0
- v6.0.0
- v5.3.0
- v5.2.0
- v5.1.0
- v5.0.0
- v4.0.0
- v3.0.0
- v2.14.0
- v2.13.3
- v2.13.2
- v2.13.1
- v2.13.0
- v2.12.0
- v2.11.1
- v2.11.0
- v2.10.0
- v2.9.0
- v2.8.0
- v2.7.0
- v2.6.0
- v2.5.0
- v2.4.0
- v2.3.0
- v2.2.0
- v2.1.0
- v2.0.0
- v1.2.2
- v1.2.1-alpha
- v1.2.0
- v1.1.1
- v1.1.0
- v1.0.0
- v0.0.10
- v0.0.1
- v0.0.0
- dev-SWI-6496
- dev-SWI-2789
- dev-SWI-2565
- dev-DX-2944
- dev-DX-2862
- dev-DX-2809
- dev-DX-2704
- dev-DX-2742
- dev-EDGE-1027
- dev-DX-2246
This package is auto-updated.
Last update: 2024-11-05 19:48:19 UTC
README
Getting Started
Installation
composer require bandwidth/sdk
Initialize
require "vendor/autoload.php"; $config = new BandwidthLib\Configuration( array( 'messagingBasicAuthUserName' => 'username', 'messagingBasicAuthPassword' => 'password', 'voiceBasicAuthUserName' => 'username', 'voiceBasicAuthPassword' => 'password', 'twoFactorAuthBasicAuthUserName' => 'username', 'twoFactorAuthBasicAuthPassword' => 'password', 'webRtcBasicAuthUserName' => 'username', 'webRtcBasicAuthPassword' => 'password' ) ); $client = new BandwidthLib\BandwidthClient($config); $accountId = "12345";
Create A Phone Call
$voiceClient = $client->getVoice()->getClient(); $body = new BandwidthLib\Voice\Models\CreateCallRequest(); $body->from = "+15554443333"; $body->to = "+15554442222"; $body->answerUrl = "https://test.com"; $body->applicationId = "3-d-4-b-5"; try { $response = $voiceClient->createCall($voiceAccountId, $body); print_r($response); } catch (Exception $e) { print_r($e); }
Send A Text Message
$messagingClient = $client->getMessaging()->getClient(); $body = new BandwidthLib\Messaging\Models\MessageRequest(); $body->from = "+12345678901"; $body->to = array("+12345678902"); $body->applicationId = "1234-ce-4567-de"; $body->text = "Greetings!"; try { $response = $messagingClient->createMessage($messagingAccountId, $body); print_r($response); } catch (Exception $e) { print_r($e); }
Create BXML
$speakSentence = BandwidthLib\Voice\Bxml\SpeakSentence::make("Hello!") ->voice("susan") ->locale("en_US") ->gender("female"); $response = BandwidthLib\Voice\Bxml\Response::make() ->addVerb($speakSentence); echo $response->toBxml();
Create A MFA Request
$mfaClient = $client->getTwoFactorAuth()->getMFA(); $body = new BandwidthLib\TwoFactorAuth\Models\TwoFactorCodeRequestSchema(); $body->from = "+15554443333"; $body->to = "+15553334444"; $body->applicationId = "3-a-b-d"; $body->scope = "scope"; $body->digits = 6; $body->message = "Your temporary {NAME} {SCOPE} code is {CODE}"; $mfaClient->createVoiceTwoFactor($accountId, $body); $body = new BandwidthLib\TwoFactorAuth\Models\TwoFactorVerifyRequestSchema(); $body->from = "+15554443333"; $body->to = "+15553334444"; $body->applicationId = "3-a-b-d"; $body->scope = "scope"; $body->code = "123456"; $body->digits = 6; $body->expirationTimeInMinutes = 3; $response = $mfaClient->createVerifyTwoFactor($accountId, $body); echo $response->getResult()->valid;
WebRtc Participant & Session Management
$webRtcClient = $client->getWebRtc()->getClient(); $createSessionBody = new BandwidthLib\WebRtc\Models\Session(); $createSessionBody->tag = 'new-session'; $createSessionResponse = $webRtcClient->createSession($accountId, $createSessionBody); $sessionId = $createSessionResponse->getResult()->id; $createParticipantBody = new BandwidthLib\WebRtc\Models\Participant(); $createParticipantBody->callbackUrl = 'https://sample.com'; $createParticipantBody->publishPermissions = array( BandwidthLib\WebRtc\Models\PublishPermissionEnum::AUDIO, BandwidthLib\WebRtc\Models\PublishPermissionEnum::VIDEO ); $body = new BandwidthLib\WebRtc\Models\Subscriptions(); $body->sessionId = "1234-abcd"; $createParticipantResponse = $webRtcClient->createParticipant($accountId, $createParticipantBody); $participantId = $createParticipantResponse->getResult()->participant->id; $webRtcClient->addParticipantToSession($accountId, $sessionId, $participantId, $body);
Supported PHP Versions
This package can be used with PHP >= 7.2
Documentation
Documentation for this package can be found at https://dev.bandwidth.com/sdks/php/
Credentials
Information for credentials for this package can be found at https://dev.bandwidth.com/guides/accountCredentials.html