forked from plivo/plivo-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f73c0b5
Showing
159 changed files
with
10,022 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.idea/ | ||
.DS_STORE | ||
phpDocumentor.phar | ||
generateDocs.sh | ||
composer.phar | ||
composer.lock | ||
vendor/ |
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 @@ | ||
language: php | ||
php: | ||
- '5.5' | ||
- '5.6' | ||
- '7.0' | ||
- '7.1' | ||
# - hhvm # on Trusty only | ||
- nightly | ||
before_install: "composer install" | ||
script: "phpunit --configuration tests/phpunit.xml" |
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,3 @@ | ||
# Authors | ||
- Kritarth ([@kritarth3010](https://github.com/kritarth3010)) | ||
- [Sreyantha Chary](https://sreyanth.com?ref=github/plivo-php) ([@sreyanth](https://github.com/sreyanth)) |
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,39 @@ | ||
# Change Log | ||
|
||
## [1.1.7](https://github.com/plivo/plivo-php/releases/tag/v1.1.7) - 2017-04-25 | ||
- API domain modified from api.plivo.io to api.plivo.com | ||
|
||
## [1.1.6](https://github.com/plivo/plivo-php/releases/tag/v1.1.6) - 2017-04-24 | ||
- API domain modified from api.plivo.com to api.plivo.io | ||
|
||
## [1.1.5](https://github.com/plivo/plivo-php/releases/tag/v1.1.5) - 2016-06-02 | ||
- Merge pull request #37 from plivo/add_param_dial_xml | ||
- Added digitsMatchBLeg parameter to Dial XML | ||
|
||
## [1.1.4](https://github.com/plivo/plivo-php/releases/tag/v1.1.4) - 2016-03-29 | ||
- now you can pass accented and non ascii characters in a Speak element and they will be properly encoded in the resulting XML | ||
|
||
## [1.1.3](https://github.com/plivo/plivo-php/releases/tag/v1.1.3) - 2016-03-01 | ||
- Removed the catching of guzzle exceptions from the request function. | ||
|
||
## [1.1.2](https://github.com/plivo/plivo-php/releases/tag/v1.1.2) - 2016-03-01 | ||
- Relaxed guzzlehttp/guzzle version requirements; any guzzlehttp/guzzle v6.0.0 and above should work just fine. | ||
|
||
## [1.1.1](https://github.com/plivo/plivo-php/releases/tag/v1.1.1) - 2016-02-11 | ||
- Added validate_signature function to RestAPI class. | ||
- closes #32 | ||
|
||
## [1.1.0](https://github.com/plivo/plivo-php/releases/tag/v1.1.0) - 2016-06-02 | ||
- closes #24 | ||
- Requires PHP 5.5 or above | ||
|
||
## [1.0.1](https://github.com/plivo/plivo-php/releases/tag/v1.0.1) - 2015-11-25 | ||
- Update README.md | ||
|
||
## [1.0.0](https://github.com/plivo/plivo-php/releases/tag/v1.0.0) - 2015-11-10 | ||
- Update README.md | ||
|
||
## [0.1.0](Live on composer) - 2015-03-13 | ||
- Adheres to standard when extending parent class (match signatures) | ||
- Makes the package installable via Composer | ||
- Replaces HTTP_Request2 with Guzzle |
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 @@ | ||
Copyright (C) 2017, Plivo Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
of the Software, and to permit persons to whom the Software is furnished to do | ||
so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,130 @@ | ||
# plivo-php | ||
|
||
[![Build Status](https://travis-ci.org/plivo/plivo-php.svg?branch=4.0)](https://travis-ci.org/plivo/plivo-php) | ||
|
||
The Plivo PHP SDK makes it simpler to integrate communications into your PHP applications using the Plivo REST API. Using the SDK, you will be able to make voice calls, send SMS and generate Plivo XML to control your call flows. | ||
|
||
## Installation | ||
You can use the SDK using [composer](https://getcomposer.org/). Run the following command in your project directory to update your `composer.json` file and download the SDK. | ||
|
||
$ composer require plivo/plivo-php | ||
|
||
Alternatively, you can download this source and run | ||
|
||
$ composer install | ||
|
||
This generates the autoload files, which you can include using the following line in your PHP source code to start using the SDK. | ||
|
||
```php | ||
<?php | ||
require 'vendor/autoload.php' | ||
``` | ||
|
||
## Getting started | ||
|
||
### Authentication | ||
|
||
To make the API requests, you need create a `RestClient` and provide it with authentication credentials (which can be found at [https://manage.plivo.com/dashboard/](https://manage.plivo.com/dashboard/)). | ||
|
||
We recommend that you store your credentials in the `PLIVO_AUTH_ID` and the `PLIVO_AUTH_TOKEN` environment variables, so as to avoid the possibility of accidentally committing them to source control. If you do this, you can initialise the client with no arguments and it will automatically fetch them from the environment variables: | ||
|
||
```php | ||
<?php | ||
require 'vendor/autoload.php'; | ||
use Plivo\RestClient; | ||
|
||
$client = new RestClient(); | ||
``` | ||
|
||
Alternatively, you can specifiy the authentication credentials while initializing the `RestClient`. | ||
|
||
```php | ||
<?php | ||
require 'vendor/autoload.php'; | ||
use Plivo\RestClient; | ||
|
||
$client = new RestClient("your_auth_id", "your_auth_token"); | ||
``` | ||
|
||
## The Basics | ||
The SDK uses consistent interfaces to create, retrieve, update, delete and list resources. The pattern followed is as follows: | ||
|
||
```php | ||
<?php | ||
$client->resources->create($params) # Create | ||
$client->resources->get($id) # Get | ||
$client->resources->update($id, $params) # Update | ||
$client->resources->delete($id) # Delete | ||
$client->resources->list() # List all resources, max 20 at a time | ||
``` | ||
|
||
You can also use the `resource` directly to update and delete it. For example, | ||
|
||
```php | ||
<?php | ||
$resource = $client->resources->get($id) | ||
$resource->update($params) # update the resource | ||
$resource->delete() # Delete the resource | ||
``` | ||
|
||
Also, using `$client->resources->list()` would list the first 20 resources by default (which is the first page, with `limit` as 20, and `offset` as 0). To get more, you will have to use `limit` and `offset` to get the second page of resources. | ||
|
||
## Examples | ||
|
||
### Send a message | ||
|
||
```php | ||
<?php | ||
require 'vendor/autoload.php'; | ||
use Plivo\RestClient; | ||
|
||
$client = new RestClient(); | ||
$message_created = $client->messages->create( | ||
'the_source_number', | ||
['the_destination_number'], | ||
'Hello, world!' | ||
); | ||
``` | ||
|
||
### Make a call | ||
|
||
```php | ||
<?php | ||
require 'vendor/autoload.php'; | ||
use Plivo\RestClient; | ||
|
||
$client = new RestClient(); | ||
$call_made = $client->calls->create( | ||
'the_source_number', | ||
['the_destination_number'], | ||
'https://answer.url' | ||
); | ||
``` | ||
|
||
### Generate Plivo XML | ||
|
||
```php | ||
<?php | ||
require 'vendor/autoload.php'; | ||
use Plivo\XML\Response; | ||
|
||
$response = new Response(); | ||
$response->addSpeak('Hello, world!'); | ||
echo($response->toXML()); | ||
``` | ||
|
||
This generates the following XML: | ||
|
||
```xml | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Response> | ||
<Speak>Hello, world!</Speak> | ||
</Response> | ||
``` | ||
|
||
|
||
### More examples | ||
Refer to the [Plivo API Reference](https://api-reference.plivo.com/latest/php/introduction/overview) for more examples. Also refer to the [guide to setting up dev environment](https://developers.plivo.com/getting-started/setting-up-dev-environment/) on [Plivo Developers Portal](https://developers.plivo.com) to setup a simple PHP server & use it to test out your integration in under 5 minutes. | ||
|
||
## Reporting issues | ||
Report any feedback or problems with this beta version by [opening an issue on Github](https://github.com/plivo/plivo-php/issues). |
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,30 @@ | ||
{ | ||
"name": "plivo/php-sdk", | ||
"description": "A PHP SDK to make voice calls & send SMS using Plivo and to generate Plivo XML", | ||
"keywords": ["plivo", "plivo xml", "voice calls", "sms", "api"], | ||
"homepage": "http://github.com/plivo/plivo-php", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Plivo SDKs Team", | ||
"email": "[email protected]", | ||
"homepage": "https://developers.plivo.com", | ||
"role": "Developer" | ||
} | ||
], | ||
"support": { | ||
"issues": "https://github.com/plivo/plivo-php/issues", | ||
"source": "https://github.com/plivo/plivo-php" | ||
}, | ||
"require": { | ||
"guzzlehttp/guzzle": "^6.0" | ||
}, | ||
"autoload": { | ||
"classmap": ["src/", "tests/"], | ||
"exclude-from-classmap": [] | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^4.8", | ||
"justinrainbow/json-schema": "^5.2" | ||
} | ||
} |
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,50 @@ | ||
<?php | ||
|
||
namespace Plivo\Authentication; | ||
|
||
|
||
/** | ||
* Class BasicAuth | ||
* @package Plivo\Authentication | ||
*/ | ||
class BasicAuth | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $authId; | ||
/** | ||
* @var string | ||
*/ | ||
protected $authToken; | ||
|
||
/** | ||
* BasicAuth constructor. | ||
* @param string|null $authId | ||
* @param string|null $authToken | ||
*/ | ||
public function __construct($authId = null, $authToken = null) | ||
{ | ||
// if null try from the environment | ||
$this->authId = $authId?:getenv('PLIVO_AUTH_ID'); | ||
$this->authToken = $authToken?:getenv('PLIVO_AUTH_TOKEN'); | ||
} | ||
|
||
/** | ||
* Returns the authentication id | ||
* @return string | ||
*/ | ||
public function getAuthId() | ||
{ | ||
return $this->authId; | ||
} | ||
|
||
/** | ||
* Returns the authentication token | ||
* @return string | ||
*/ | ||
public function getAuthToken() | ||
{ | ||
return $this->authToken; | ||
} | ||
} |
Oops, something went wrong.