{"id":20364351,"url":"https://github.com/bandwidth/php-sdk","last_synced_at":"2025-04-12T04:41:41.904Z","repository":{"id":39636324,"uuid":"209614725","full_name":"Bandwidth/php-sdk","owner":"Bandwidth","description":"PHP SDK for Bandwidth Voice \u0026 Messaging","archived":false,"fork":false,"pushed_at":"2024-02-28T14:38:07.000Z","size":290,"stargazers_count":13,"open_issues_count":1,"forks_count":7,"subscribers_count":38,"default_branch":"main","last_synced_at":"2024-04-29T22:07:31.837Z","etag":null,"topics":["sdk","sdlc-enforced"],"latest_commit_sha":null,"homepage":"https://dev.bandwidth.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Bandwidth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-19T17:46:25.000Z","updated_at":"2024-06-18T22:37:16.188Z","dependencies_parsed_at":"2024-01-04T15:29:23.021Z","dependency_job_id":"745ab391-58b9-464a-88e9-32bc9696352c","html_url":"https://github.com/Bandwidth/php-sdk","commit_stats":{"total_commits":114,"total_committers":10,"mean_commits":11.4,"dds":0.7456140350877193,"last_synced_commit":"2c44088bdbfc072842df7ff0ab9853e8c7a70f50"},"previous_names":[],"tags_count":56,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bandwidth%2Fphp-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bandwidth%2Fphp-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bandwidth%2Fphp-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bandwidth%2Fphp-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bandwidth","download_url":"https://codeload.github.com/Bandwidth/php-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248519307,"owners_count":21117756,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["sdk","sdlc-enforced"],"created_at":"2024-11-15T00:11:23.295Z","updated_at":"2025-04-12T04:41:41.898Z","avatar_url":"https://github.com/Bandwidth.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bandwidth PHP SDK\n\n[![Test](https://github.com/Bandwidth/php-sdk/actions/workflows/test.yml/badge.svg)](https://github.com/Bandwidth/php-sdk/actions/workflows/test.yml)\n\n|    **OS**    |      **PHP**       |\n|:------------:|:------------------:|\n| Windows 2019 | 8.0, 8.1, 8.2, 8.3 |\n| Windows 2022 | 8.0, 8.1, 8.2, 8.3 |\n| Ubuntu 22.04 | 8.0, 8.1, 8.2, 8.3 |\n| Ubuntu 24.04 | 8.0, 8.1, 8.2, 8.3 |\n\n## Getting Started\n\n### Installation\n\n```\ncomposer require bandwidth/sdk\n```\n\n### Initialize\n\n```php\n\nrequire \"vendor/autoload.php\";\n\n$config = new BandwidthLib\\Configuration(\n    array(\n        'messagingBasicAuthUserName' =\u003e 'username',\n        'messagingBasicAuthPassword' =\u003e 'password',\n        'voiceBasicAuthUserName' =\u003e 'username',\n        'voiceBasicAuthPassword' =\u003e 'password',\n        'twoFactorAuthBasicAuthUserName' =\u003e 'username',\n        'twoFactorAuthBasicAuthPassword' =\u003e 'password',\n        'webRtcBasicAuthUserName' =\u003e 'username',\n        'webRtcBasicAuthPassword' =\u003e 'password'\n    )\n);\n$client = new BandwidthLib\\BandwidthClient($config);\n$accountId = \"12345\";\n```\n\n### Create A Phone Call\n\n```php\n\n$voiceClient = $client-\u003egetVoice()-\u003egetClient();\n\n$body = new BandwidthLib\\Voice\\Models\\CreateCallRequest();\n$body-\u003efrom = \"+15554443333\";\n$body-\u003eto = \"+15554442222\";\n$body-\u003eanswerUrl = \"https://test.com\";\n$body-\u003eapplicationId = \"3-d-4-b-5\";\n\ntry {\n    $response = $voiceClient-\u003ecreateCall($voiceAccountId, $body);\n    print_r($response);\n} catch (Exception $e) {\n    print_r($e);\n}\n```\n\n### Send A Text Message\n\n```php\n\n$messagingClient = $client-\u003egetMessaging()-\u003egetClient();\n\n$body = new BandwidthLib\\Messaging\\Models\\MessageRequest();\n$body-\u003efrom = \"+12345678901\";\n$body-\u003eto = array(\"+12345678902\");\n$body-\u003eapplicationId = \"1234-ce-4567-de\";\n$body-\u003etext = \"Greetings!\";\n\ntry {\n    $response = $messagingClient-\u003ecreateMessage($messagingAccountId, $body);\n    print_r($response);\n} catch (Exception $e) {\n    print_r($e);\n}\n```\n\n### Create BXML\n\n```php\n\n$speakSentence = BandwidthLib\\Voice\\Bxml\\SpeakSentence::make(\"Hello!\")\n    -\u003evoice(\"susan\")\n    -\u003elocale(\"en_US\")\n    -\u003egender(\"female\");\n$response = BandwidthLib\\Voice\\Bxml\\Response::make()\n    -\u003eaddVerb($speakSentence);\necho $response-\u003etoBxml();\n```\n\n### Create A MFA Request\n\n```php\n\n$mfaClient = $client-\u003egetTwoFactorAuth()-\u003egetMFA();\n\n$body = new BandwidthLib\\TwoFactorAuth\\Models\\TwoFactorCodeRequestSchema();\n$body-\u003efrom = \"+15554443333\";\n$body-\u003eto = \"+15553334444\";\n$body-\u003eapplicationId = \"3-a-b-d\";\n$body-\u003escope = \"scope\";\n$body-\u003edigits = 6;\n$body-\u003emessage = \"Your temporary {NAME} {SCOPE} code is {CODE}\";\n$mfaClient-\u003ecreateVoiceTwoFactor($accountId, $body);\n\n$body = new BandwidthLib\\TwoFactorAuth\\Models\\TwoFactorVerifyRequestSchema();\n$body-\u003efrom = \"+15554443333\";\n$body-\u003eto = \"+15553334444\";\n$body-\u003eapplicationId = \"3-a-b-d\";\n$body-\u003escope = \"scope\";\n$body-\u003ecode = \"123456\";\n$body-\u003edigits = 6;\n$body-\u003eexpirationTimeInMinutes = 3;\n\n$response = $mfaClient-\u003ecreateVerifyTwoFactor($accountId, $body);\necho $response-\u003egetResult()-\u003evalid;\n```\n\n### WebRtc Participant \u0026 Session Management\n\n```php\n\n$webRtcClient = $client-\u003egetWebRtc()-\u003egetClient();\n\n$createSessionBody = new BandwidthLib\\WebRtc\\Models\\Session();\n$createSessionBody-\u003etag = 'new-session';\n\n$createSessionResponse = $webRtcClient-\u003ecreateSession($accountId, $createSessionBody);\n$sessionId = $createSessionResponse-\u003egetResult()-\u003eid;\n\n$createParticipantBody = new BandwidthLib\\WebRtc\\Models\\Participant();\n$createParticipantBody-\u003ecallbackUrl = 'https://sample.com';\n$createParticipantBody-\u003epublishPermissions = array(\n    BandwidthLib\\WebRtc\\Models\\PublishPermissionEnum::AUDIO,\n    BandwidthLib\\WebRtc\\Models\\PublishPermissionEnum::VIDEO\n);\n\n$body = new BandwidthLib\\WebRtc\\Models\\Subscriptions();\n$body-\u003esessionId = \"1234-abcd\";\n\n$createParticipantResponse = $webRtcClient-\u003ecreateParticipant($accountId, $createParticipantBody);\n$participantId = $createParticipantResponse-\u003egetResult()-\u003eparticipant-\u003eid;\n\n$webRtcClient-\u003eaddParticipantToSession($accountId, $sessionId, $participantId, $body);\n```\n\n## Supported PHP Versions\n\nThis package can be used with PHP \u003e= 7.2\n\n## Documentation\n\nDocumentation for this package can be found at [https://dev.bandwidth.com/sdks/php/](https://dev.bandwidth.com/sdks/php/)\n\n## Credentials\n\nInformation for credentials for this package can be found at https://dev.bandwidth.com/guides/accountCredentials.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbandwidth%2Fphp-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbandwidth%2Fphp-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbandwidth%2Fphp-sdk/lists"}