Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 18482a0

Browse files
Revert "Revert "Update README.md""
This reverts commit c6a777f.
1 parent c6a777f commit 18482a0

File tree

1 file changed

+20
-346
lines changed

1 file changed

+20
-346
lines changed

β€ŽREADME.mdβ€Ž

Lines changed: 20 additions & 346 deletions
Original file line numberDiff line numberDiff line change
@@ -1,366 +1,40 @@
1-
# Getting started
1+
# MessageMedia Webhooks PHP SDK
2+
[![Travis Build Status](https://api.travis-ci.org/messagemedia/webhooks-php-sdk.svg?branch=master)](https://travis-ci.org/messagemedia/webhooks-php-sdk)
23

3-
TODO: Add a description
4+
The MessageMedia Webhooks allows you to subscribe to one or several events and when one of those events is triggered, an HTTP request is sent to the URL of your choice along with the message or payload. In simpler terms, it allows applications to "speak" to one another and get notified automatically when something new happens.
45

5-
## How to Build
6-
7-
The generated code has dependencies over external libraries like UniRest. These dependencies are defined in the ```composer.json``` file that comes with the SDK.
8-
To resolve these dependencies, we use the Composer package manager which requires PHP greater than 5.3.2 installed in your system.
9-
Visit [https://getcomposer.org/download/](https://getcomposer.org/download/) to download the installer file for Composer and run it in your system.
10-
Open command prompt and type ```composer --version```. This should display the current version of the Composer installed if the installation was successful.
11-
12-
* Using command line, navigate to the directory containing the generated files (including ```composer.json```) for the SDK.
13-
* Run the command ```composer install```. This should install all the required dependencies and create the ```vendor``` directory in your project directory.
14-
15-
![Building SDK - Step 1](https://apidocs.io/illustration/php?step=installDependencies&workspaceFolder=MessageMediaWebhooks-PHP)
16-
17-
### [For Windows Users Only] Configuring CURL Certificate Path in php.ini
18-
19-
CURL used to include a list of accepted CAs, but no longer bundles ANY CA certs. So by default it will reject all SSL certificates as unverifiable. You will have to get your CA's cert and point curl at it. The steps are as follows:
20-
21-
1. Download the certificate bundle (.pem file) from [https://curl.haxx.se/docs/caextract.html](https://curl.haxx.se/docs/caextract.html) on to your system.
22-
2. Add curl.cainfo = "PATH_TO/cacert.pem" to your php.ini file located in your php installation. "PATH_TO" must be an absolute path containing the .pem file.
23-
24-
```ini
25-
[curl]
26-
; A default value for the CURLOPT_CAINFO option. This is required to be an
27-
; absolute path.
28-
;curl.cainfo =
6+
## ⭐️ Installing via Composer
7+
Run the Composer command to install the latest stable version of the Messages SDK:
298
```
30-
31-
## How to Use
32-
33-
The following section explains how to use the MessageMediaWebhooks library in a new project.
34-
35-
### 1. Open Project in an IDE
36-
37-
Open an IDE for PHP like PhpStorm. The basic workflow presented here is also applicable if you prefer using a different editor or IDE.
38-
39-
![Open project in PHPStorm - Step 1](https://apidocs.io/illustration/php?step=openIDE&workspaceFolder=MessageMediaWebhooks-PHP)
40-
41-
Click on ```Open``` in PhpStorm to browse to your generated SDK directory and then click ```OK```.
42-
43-
![Open project in PHPStorm - Step 2](https://apidocs.io/illustration/php?step=openProject0&workspaceFolder=MessageMediaWebhooks-PHP)
44-
45-
### 2. Add a new Test Project
46-
47-
Create a new directory by right clicking on the solution name as shown below:
48-
49-
![Add a new project in PHPStorm - Step 1](https://apidocs.io/illustration/php?step=createDirectory&workspaceFolder=MessageMediaWebhooks-PHP)
50-
51-
Name the directory as "test"
52-
53-
![Add a new project in PHPStorm - Step 2](https://apidocs.io/illustration/php?step=nameDirectory&workspaceFolder=MessageMediaWebhooks-PHP)
54-
55-
Add a PHP file to this project
56-
57-
![Add a new project in PHPStorm - Step 3](https://apidocs.io/illustration/php?step=createFile&workspaceFolder=MessageMediaWebhooks-PHP)
58-
59-
Name it "testSDK"
60-
61-
![Add a new project in PHPStorm - Step 4](https://apidocs.io/illustration/php?step=nameFile&workspaceFolder=MessageMediaWebhooks-PHP)
62-
63-
Depending on your project setup, you might need to include composer's autoloader in your PHP code to enable auto loading of classes.
64-
65-
```PHP
66-
require_once "../vendor/autoload.php";
9+
composer require messagemedia/messages-sdk
6710
```
6811

69-
It is important that the path inside require_once correctly points to the file ```autoload.php``` inside the vendor directory created during dependency installations.
70-
71-
![Add a new project in PHPStorm - Step 4](https://apidocs.io/illustration/php?step=projectFiles&workspaceFolder=MessageMediaWebhooks-PHP)
72-
73-
After this you can add code to initialize the client library and acquire the instance of a Controller class. Sample code to initialize the client library and using controller methods is given in the subsequent sections.
74-
75-
### 3. Run the Test Project
76-
77-
To run your project you must set the Interpreter for your project. Interpreter is the PHP engine installed on your computer.
78-
79-
Open ```Settings``` from ```File``` menu.
80-
81-
![Run Test Project - Step 1](https://apidocs.io/illustration/php?step=openSettings&workspaceFolder=MessageMediaWebhooks-PHP)
82-
83-
Select ```PHP``` from within ```Languages & Frameworks```
84-
85-
![Run Test Project - Step 2](https://apidocs.io/illustration/php?step=setInterpreter0&workspaceFolder=MessageMediaWebhooks-PHP)
86-
87-
Browse for Interpreters near the ```Interpreter``` option and choose your interpreter.
88-
89-
![Run Test Project - Step 3](https://apidocs.io/illustration/php?step=setInterpreter1&workspaceFolder=MessageMediaWebhooks-PHP)
90-
91-
Once the interpreter is selected, click ```OK```
92-
93-
![Run Test Project - Step 4](https://apidocs.io/illustration/php?step=setInterpreter2&workspaceFolder=MessageMediaWebhooks-PHP)
94-
95-
To run your project, right click on your PHP file inside your Test project and click on ```Run```
96-
97-
![Run Test Project - Step 5](https://apidocs.io/illustration/php?step=runProject&workspaceFolder=MessageMediaWebhooks-PHP)
98-
99-
## How to Test
100-
101-
Unit tests in this SDK can be run using PHPUnit.
102-
103-
1. First install the dependencies using composer including the `require-dev` dependencies.
104-
2. Run `vendor\bin\phpunit --verbose` from commandline to execute tests. If you have
105-
installed PHPUnit globally, run tests using `phpunit --verbose` instead.
106-
107-
You can change the PHPUnit test configuration in the `phpunit.xml` file.
108-
109-
## Initialization
110-
111-
### Authentication
112-
In order to setup authentication and initialization of the API client, you need the following information.
113-
114-
| Parameter | Description |
115-
|-----------|-------------|
116-
| basicAuthUserName | The username to use with basic authentication |
117-
| basicAuthPassword | The password to use with basic authentication |
118-
119-
120-
121-
API client can be initialized as following.
12+
## 🎬 Get Started
13+
It's easy to get started. Simply enter the API Key and secret you obtained from the [MessageMedia Developers Portal](https://developers.messagemedia.com) into the code snippet below and a mobile number you wish to send to.
12214

15+
### πŸš€ Create a webhook
12316
```php
124-
$basicAuthUserName = 'basicAuthUserName'; // The username to use with basic authentication
125-
$basicAuthPassword = 'basicAuthPassword'; // The password to use with basic authentication
126-
127-
$client = new MessageMediaWebhooksLib\MessageMediaWebhooksClient($basicAuthUserName, $basicAuthPassword);
12817
```
12918

130-
131-
# Class Reference
132-
133-
## <a name="list_of_controllers"></a>List of Controllers
134-
135-
* [APIController](#api_controller)
136-
137-
## <a name="api_controller"></a>![Class: ](https://apidocs.io/img/class.png ".APIController") APIController
138-
139-
### Get singleton instance
140-
141-
The singleton instance of the ``` APIController ``` class can be accessed from the API Client.
142-
19+
### πŸ“₯ Retrieve all webhooks
14320
```php
144-
$client = $client->getClient();
14521
```
14622

147-
### <a name="create"></a>![Method: ](https://apidocs.io/img/method.png ".APIController.create") create
148-
149-
> This will create a webhook for the specified `events`
150-
> ### Parameters
151-
> **list of supported parameters in `template` according to the message type :**
152-
> you must escape the json for the template parameter. see example .
153-
> | Data | parameter name | DR| MO | MO MMS | Comment |
154-
> |:--|--|--|--|--|--|
155-
> | **service type** | $type| ``OK`` |`OK`| `OK`| |
156-
> | **Message ID** | $mtId, $messageId| `OK` |`OK`| `OK`| |
157-
> | **Delivery report ID** |$drId, $reportId | `OK` || | |
158-
> | **Reply ID**| $moId, $replyId| |`OK`| `OK`||
159-
> | **Account ID** | $accountId| `OK` |`OK`| `OK`||
160-
> | **Message Timestamp** | $submittedTimestamp| `OK` |`OK`| `OK`||
161-
> | **Provider Timestamp** | $receivedTimestamp| `OK` |`OK`| `OK`||
162-
> | **Message status** | $status| `OK` ||||
163-
> | **Status code** | $statusCode| `OK` ||||
164-
> | **External metadata** | $metadata.get('key')| `OK` |`OK`| `OK`||
165-
> | **Source address**| $sourceAddress| `OK` |`OK`| `OK`||
166-
> | **Destination address**| $destinationAddress| |`OK`| `OK`||
167-
> | **Message content**| $mtContent, $messageContent| `OK` |`OK`| `OK`||
168-
> | **Reply Content**| $moContent, $replyContent| |`OK`| `OK`||
169-
> | **Retry Count**| $retryCount| `OK` |`OK`| `OK`||
170-
> **list of allowed `events` :**
171-
> you can combine all the events whatever the message type.(at least one Event set otherwise the webhook won't be created)
172-
> + **events for SMS**
173-
> + `RECEIVED_SMS`
174-
> + `OPT_OUT_SMS`
175-
> + **events for MMS**
176-
> + `RECEIVED_MMS`
177-
> + **events for DR**
178-
> + `ENROUTE_DR`
179-
> + `EXPIRED_DR`
180-
> + `REJECTED_DR`
181-
> + `FAILED_DR`
182-
> + `DELIVERED_DR`
183-
> + `SUBMITTED_DR`
184-
> a **Response 400 is returned when** :
185-
> <ul>
186-
> <li>the `url` is not valid </li>
187-
> <li>the `events` is null/empty </li>
188-
> <li>the `encoding` is null </li>
189-
> <li>the `method` is null </li>
190-
> <li>the `headers` has a `ContentType` attribute </li>
191-
> </ul>
192-
193-
23+
### πŸ”„ Update a webhook
24+
You can get a webhook ID by looking at the `id` of each webhook created from the response of the above example.
19425
```php
195-
function create(
196-
$contentType,
197-
$body)
19826
```
19927

200-
#### Parameters
201-
202-
| Parameter | Tags | Description |
203-
|-----------|------|-------------|
204-
| contentType | ``` Required ``` | TODO: Add a parameter description |
205-
| body | ``` Required ``` | TODO: Add a parameter description |
206-
207-
208-
209-
#### Example Usage
210-
28+
### ❌ Delete a webhook
29+
You can get a webhook ID by looking at the `id` of each webhook created from the response of the retrieve webhooks example.
21130
```php
212-
$contentType = 'Content-Type';
213-
$body = new CreateRequest();
214-
215-
$result = $client->create($contentType, $body);
216-
21731
```
21832

219-
#### Errors
220-
221-
| Error Code | Error Description |
222-
|------------|-------------------|
223-
| 400 | TODO: Add an error description |
224-
225-
226-
227-
### <a name="delete_delete_and_update_webhook"></a>![Method: ](https://apidocs.io/img/method.png ".APIController.deleteDeleteAndUpdateWebhook") deleteDeleteAndUpdateWebhook
228-
229-
> This will delete the webhook wuth the give id.
230-
> a **Response 404 is returned when** :
231-
> <ul>
232-
> <li>there is no webhook with this `webhookId` </li>
233-
> </ul>
234-
235-
236-
```php
237-
function deleteDeleteAndUpdateWebhook($webhookId)
238-
```
239-
240-
#### Parameters
241-
242-
| Parameter | Tags | Description |
243-
|-----------|------|-------------|
244-
| webhookId | ``` Required ``` | TODO: Add a parameter description |
245-
246-
247-
248-
#### Example Usage
249-
250-
```php
251-
$webhookId = a7f11bb0-f299-4861-a5ca-9b29d04bc5ad;
252-
253-
$client->deleteDeleteAndUpdateWebhook($webhookId);
254-
255-
```
256-
257-
#### Errors
258-
259-
| Error Code | Error Description |
260-
|------------|-------------------|
261-
| 404 | TODO: Add an error description |
262-
263-
264-
265-
### <a name="retrieve"></a>![Method: ](https://apidocs.io/img/method.png ".APIController.retrieve") retrieve
266-
267-
> This will retrieve all webhooks for the account we're connected with.
268-
> a **Response 400 is returned when** :
269-
> <ul>
270-
> <li>the `page` query parameter is not valid </li>
271-
> <li>the `pageSize` query parameter is not valid </li>
272-
> </ul>
273-
274-
275-
```php
276-
function retrieve(
277-
$page = null,
278-
$pageSize = null)
279-
```
280-
281-
#### Parameters
282-
283-
| Parameter | Tags | Description |
284-
|-----------|------|-------------|
285-
| page | ``` Optional ``` | TODO: Add a parameter description |
286-
| pageSize | ``` Optional ``` | TODO: Add a parameter description |
287-
288-
289-
290-
#### Example Usage
291-
292-
```php
293-
$page = '1';
294-
$pageSize = '10';
295-
296-
$result = $client->retrieve($page, $pageSize);
297-
298-
```
299-
300-
#### Errors
301-
302-
| Error Code | Error Description |
303-
|------------|-------------------|
304-
| 400 | TODO: Add an error description |
305-
306-
307-
308-
### <a name="update"></a>![Method: ](https://apidocs.io/img/method.png ".APIController.update") update
309-
310-
> This will update a webhook and returned the updated Webhook.
311-
> you can update all the attributes individually or together.
312-
> PS : the new value will override the previous one.
313-
> ### Parameters
314-
> + same parameters rules as create webhook apply
315-
> a **Response 404 is returned when** :
316-
> <ul>
317-
> <li>there is no webhook with this `webhookId` </li>
318-
> </ul>
319-
> a **Response 400 is returned when** :
320-
> <ul>
321-
> <li>all attributes are null </li>
322-
> <li>events array is empty </li>
323-
> <li>content-Type is set in the headers instead of using the `encoding` attribute </li>
324-
> </ul>
325-
326-
327-
```php
328-
function update(
329-
$webhookId,
330-
$contentType,
331-
$body)
332-
```
333-
334-
#### Parameters
335-
336-
| Parameter | Tags | Description |
337-
|-----------|------|-------------|
338-
| webhookId | ``` Required ``` | TODO: Add a parameter description |
339-
| contentType | ``` Required ``` | TODO: Add a parameter description |
340-
| body | ``` Required ``` | TODO: Add a parameter description |
341-
342-
343-
344-
#### Example Usage
345-
346-
```php
347-
$webhookId = uniqid();
348-
$contentType = 'Content-Type';
349-
$body = new UpdateRequest();
350-
351-
$client->update($webhookId, $contentType, $body);
352-
353-
```
354-
355-
#### Errors
356-
357-
| Error Code | Error Description |
358-
|------------|-------------------|
359-
| 404 | TODO: Add an error description |
360-
361-
362-
363-
[Back to List of Controllers](#list_of_controllers)
364-
33+
## πŸ“• Documentation
34+
Check out the [full API documentation](DOCUMENTATION.md) for more detailed information.
36535

36+
## πŸ˜• Need help?
37+
Please contact developer support at developers@messagemedia.com or check out the developer portal at [developers.messagemedia.com](https://developers.messagemedia.com/)
36638

39+
## πŸ“ƒ License
40+
Apache License. See the [LICENSE](LICENSE) file.

0 commit comments

Comments
(0)

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /