Browse code

added appinfo/info.xml appinfo/signature.json CHANGELOG.txt lib/AppInfo/Application.php css/style.css providers/Plivo

DoubleBastionAdmin authored on 05/11/2025 13:35:09
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,632 @@
1
+# plivo-php
2
+
3
+[![UnitTests](https://github.com/plivo/plivo-php/actions/workflows/unitTests.yml/badge.svg?branch=master&event=push)](https://github.com/plivo/plivo-php/actions/workflows/unitTests.yml)
4
+
5
+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.
6
+
7
+**Supported PHP Versions**: This SDK works with PHP 7.3+.
8
+
9
+## Installation
10
+
11
+### To install Composer
12
+#### Globally in Mac
13
+
14
+1. Download the latest version of [Composer](https://getcomposer.org/download/). 
15
+2. Run the following command in Terminal: 
16
+        
17
+        $ php ~/Downloads/composer.phar --version
18
+
19
+3. Run the following command to make it executable:
20
+        
21
+        $ cp ~/Downloads/composer.phar /usr/local/bin/composer
22
+        $ sudo chmod +x /usr/local/bin/composer
23
+        $ Make sure you move the file to bin directory.
24
+
25
+4. To check if the path has **/usr/local/bin**, use 
26
+        
27
+        $ echo $PATH
28
+
29
+   If the path is different, use the following command to update the $PATH:    
30
+            
31
+        $ export PATH = $PATH:/usr/local/bin
32
+        $ source ~/.bash_profile 
33
+
34
+4. You can also check the version of Composer by running the following command:
35
+        
36
+        $ composer --version.       
37
+
38
+#### Globally in Linux
39
+
40
+1. Run the following command:
41
+        
42
+        $ curl -sS https://getcomposer.org/installer | php
43
+
44
+2. Run the following command to make the composer.phar file as executable:
45
+        
46
+        $ chmod +x composer.phar
47
+
48
+3. Run the following command to make Composer globally available for all system users:
49
+        
50
+        $ mv composer.phar /usr/local/bin/composer
51
+
52
+#### Windows 10
53
+
54
+1. Download and run the [Windows Installer](https://getcomposer.org/download/) for Composer.
55
+
56
+    **Note:** Make sure to allow Windows Installer for Composer to make changes to your **php.ini** file.
57
+
58
+2. If you have any terminal windows open, close all instances and open a fresh terminal instance.
59
+3. Run the Composer command.
60
+        
61
+        $ composer -V
62
+
63
+### Steps to install Plivo Package
64
+
65
+- To install the **stable release**, run the following command in the project directory:
66
+        
67
+        $ composer require plivo/plivo-php
68
+
69
+- To install a **specific release**, run the following command in the project directory:
70
+        
71
+        $ composer require plivo/plivo-php:4.14.0
72
+
73
+- To test the features in the **beta release**, run the following command in the project directory:
74
+        
75
+        $ composer require plivo/plivo-php:v4.2-beta1
76
+
77
+- Alternatively, you can download this source and run
78
+        
79
+        $ composer install
80
+
81
+This generates the autoload files, which you can include using the following line in your PHP source code to start using the SDK.
82
+
83
+```php
84
+<?php
85
+require 'vendor/autoload.php'
86
+```
87
+
88
+## Getting started
89
+
90
+### Authentication
91
+
92
+To make the API requests, you need to create a `RestClient` and provide it with authentication credentials (which can be found at [https://console.plivo.com/dashboard/](https://console.plivo.com/dashboard/)).
93
+
94
+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:
95
+
96
+```php
97
+<?php
98
+require 'vendor/autoload.php';
99
+use Plivo\RestClient;
100
+
101
+$client = new RestClient();
102
+```
103
+
104
+Alternatively, you can specifiy the authentication credentials while initializing the `RestClient`.
105
+
106
+```php
107
+<?php
108
+require 'vendor/autoload.php';
109
+use Plivo\RestClient;
110
+
111
+$client = new RestClient("<auth_id>", "<auth_token>");
112
+```
113
+
114
+## The Basics
115
+The SDK uses consistent interfaces to create, retrieve, update, delete and list resources. The pattern followed is as follows:
116
+
117
+```php
118
+<?php
119
+$client->resources->create($params) # Create
120
+$client->resources->get($id) # Get
121
+$client->resources->update($id, $params) # Update
122
+$client->resources->delete($id) # Delete
123
+$client->resources->list() # List all resources, max 20 at a time
124
+```
125
+
126
+You can also use the `resource` directly to update and delete it. For example,
127
+
128
+```php
129
+<?php
130
+$resource = $client->resources->get($id)
131
+$resource->update($params) # update the resource
132
+$resource->delete() # Delete the resource
133
+```
134
+
135
+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.
136
+
137
+## Examples
138
+
139
+### Send a message
140
+
141
+```php
142
+<?php
143
+require 'vendor/autoload.php';
144
+use Plivo\RestClient;
145
+
146
+$client = new RestClient();
147
+$message_created = $client->messages->create([ 
148
+        "src" => "+14156667778", 
149
+        "dst" => "+14156667777", 
150
+        "text"  =>"Hello, this is a sample text from Plivo"
151
+]);
152
+```
153
+
154
+### Make a call
155
+
156
+```php
157
+<?php
158
+require 'vendor/autoload.php';
159
+use Plivo\RestClient;
160
+
161
+$client = new RestClient();
162
+$call_made = $client->calls->create(
163
+    '+14156667778',
164
+    ['+14156667777'],
165
+    'https://answer.url'
166
+);
167
+```
168
+
169
+### Lookup a number
170
+
171
+```php
172
+<?php
173
+require 'vendor/autoload.php';
174
+use Plivo\RestClient;
175
+
176
+$client = new RestClient("<auth_id>", "<auth_token>");
177
+$response = $client->lookup->get("<number-goes-here>");
178
+```
179
+
180
+### Generate Plivo XML
181
+
182
+```php
183
+<?php
184
+require 'vendor/autoload.php';
185
+use Plivo\XML\Response;
186
+
187
+$response = new Response();
188
+$response->addSpeak('Hello, world!');
189
+echo($response->toXML());
190
+```
191
+
192
+This generates the following XML:
193
+
194
+```xml
195
+<?xml version="1.0" encoding="utf-8"?>
196
+<Response>
197
+  <Speak>Hello, world!</Speak>
198
+</Response>
199
+```
200
+
201
+### Run a PHLO
202
+
203
+```php
204
+<?php
205
+/**
206
+ * Example for API Request
207
+ */
208
+require 'vendor/autoload.php';
209
+use Plivo\Resources\PHLO\PhloRestClient;
210
+use Plivo\Exceptions\PlivoRestException;
211
+$client = new PhloRestClient("<auth_id>", "<auth_token>");
212
+$phlo = $client->phlo->get("<phlo_id>");
213
+try {
214
+    $response = $phlo->run(["field1" => "value1", "field2" => "value2"]); // These are the fields entered in the PHLO console
215
+    print_r($response);
216
+} catch (PlivoRestException $ex) {
217
+    print_r($ex);
218
+}
219
+?>
220
+```
221
+
222
+## WhatsApp Messaging
223
+Plivo's WhatsApp API allows you to send different types of messages over WhatsApp, including templated messages, free form messages and interactive messages. Below are some examples on how to use the Plivo Go SDK to send these types of messages.
224
+
225
+### Templated Messages
226
+Templated messages are a crucial to your WhatsApp messaging experience, as businesses can only initiate WhatsApp conversation with their customers using templated messages.
227
+
228
+WhatsApp templates support 4 components:  `header` ,  `body`,  `footer`  and `button`. At the point of sending messages, the template object you see in the code acts as a way to pass the dynamic values within these components.  `header`  can accomodate `text` or `media` (images, video, documents) content.  `body`  can accomodate text content.  `button`  can support dynamic values in a `url` button or to specify a developer-defined payload which will be returned when the WhatsApp user clicks on the `quick_reply` button. `footer`  cannot have any dynamic variables.
229
+
230
+Example:
231
+```php
232
+<?php
233
+require 'vendor/autoload.php';
234
+use Plivo\RestClient;
235
+
236
+$client = new RestClient("<auth_id>","<auth_token>");
237
+
238
+$template = '{ 
239
+            "name": "template_name",
240
+            "language": "en_US",
241
+            "components": [
242
+                {
243
+                    "type": "header",
244
+                    "parameters": [
245
+                        {
246
+                            "type": "media",
247
+                            "media": "https://xyz.com/s3/img.jpg"
248
+                        }
249
+                    ]
250
+                },
251
+                {
252
+                    "type": "body",
253
+                    "parameters": [
254
+                        {
255
+                            "type": "text",
256
+                            "text": "WA-Text"
257
+                        }
258
+                    ]
259
+                }
260
+            ]
261
+          }';
262
+
263
+$response = $client->messages->create([  
264
+        "src" => "+14156667778",
265
+        "dst" => "+14156667777",
266
+        "type"=> "whatsapp",
267
+        "template"=> $template,
268
+        "url"=> "https://foo.com/wa_status/"
269
+]);
270
+print_r($response);
271
+?>
272
+```
273
+
274
+### Templated WhatsApp Messages With Named Parameter
275
+This guide shows how to send templated WhatsApp messages with named parameters.
276
+
277
+Example:
278
+```php
279
+<?php
280
+require 'vendor/autoload.php';
281
+use Plivo\RestClient;
282
+
283
+$client = new RestClient("<auth_id>","<auth_token>");
284
+
285
+$template = '{ 
286
+            "name": "template_name",
287
+            "language": "en_US",
288
+            "components": [
289
+                {
290
+                    "type": "header",
291
+                    "parameters": [
292
+                        {
293
+                            "type": "text",
294
+                            "parameter_name": "header_title",
295
+                            "text": "WA-header"
296
+                        }
297
+                    ]
298
+                },
299
+                {
300
+                    "type": "body",
301
+                    "parameters": [
302
+                        {
303
+                            "type": "text",
304
+                            "parameter_name": "user_name",
305
+                            "text": "Saurabh"
306
+                        }
307
+                    ]
308
+                }
309
+            ]
310
+          }';
311
+
312
+$response = $client->messages->create([  
313
+        "src" => "+14156667778",
314
+        "dst" => "+14156667777",
315
+        "type"=> "whatsapp",
316
+        "template"=> $template,
317
+        "url"=> "https://foo.com/wa_status/"
318
+]);
319
+print_r($response);
320
+?>
321
+```
322
+
323
+### Free Form Messages
324
+Non-templated or Free Form WhatsApp messages can be sent as a reply to a user-initiated conversation (Service conversation) or if there is an existing ongoing conversation created previously by sending a templated WhatsApp message.
325
+
326
+#### Free Form Text Message
327
+Example:
328
+```php
329
+<?php
330
+require 'vendor/autoload.php';
331
+use Plivo\RestClient;
332
+
333
+$client = new RestClient("<auth_id>","<auth_token>");
334
+$response = $client->messages->create([  
335
+        "src"=> "+14156667778",
336
+        "dst"=> "+14156667777",
337
+        "text"=> "Hello, this is sample text",
338
+        "type"=> "whatsapp",
339
+        "url"=> "https://foo.com/wa_status/"
340
+]);
341
+print_r($response);
342
+?>
343
+```
344
+
345
+#### Free Form Media Message
346
+Example:
347
+```php
348
+<?php
349
+require 'vendor/autoload.php';
350
+use Plivo\RestClient;
351
+
352
+$client = new RestClient("<auth_id>","<auth_token>");
353
+$response = $client->messages->create([  
354
+        "src"=> "+14156667778",
355
+        "dst"=> "+14156667777",
356
+        "text"=> "Hello, this is sample text",
357
+        "type"=> "whatsapp",
358
+        "media_urls"=> ["https://sample-videos.com/img/Sample-png-image-1mb.png"],
359
+        "url"=> "https://foo.com/wa_status/"
360
+]);
361
+print_r($response);
362
+?>
363
+```
364
+
365
+### Interactive Messages
366
+This guide shows how to send non-templated interactive messages to recipients using Plivo’s APIs.
367
+
368
+#### Quick Reply Buttons
369
+Quick reply buttons allow customers to quickly respond to your message with predefined options.
370
+
371
+Example:
372
+```php
373
+<?php
374
+require '/usr/src/app/vendor/autoload.php';
375
+use Plivo\RestClient;
376
+
377
+$client = new RestClient("<auth_id>","<auth_token>");
378
+
379
+$interactive = '{
380
+        "type": "button",
381
+        "header": {
382
+            "type": "media",
383
+            "media": "https://xyz.com/s3/img.jpg"
384
+        },
385
+        "body": {
386
+            "text": "Make your selection"
387
+        },
388
+        "action": {
389
+            "buttons": [
390
+                {
391
+                    "title": "Click here",
392
+                    "id": "bt1"
393
+                },
394
+                {
395
+                    "title": "Know More",
396
+                    "id": "bt2"
397
+                },
398
+                {
399
+                    "title": "Request Callback",
400
+                    "id": "bt3"
401
+                }
402
+            ]
403
+        }
404
+    }';
405
+
406
+$response = $client->messages->create([
407
+        "src"=> "+14156667778",
408
+        "dst"=> "+14156667777",
409
+        "type"=> "whatsapp",
410
+        "interactive"=> $interactive
411
+]);
412
+print_r($response);
413
+?>
414
+```
415
+
416
+#### Interactive Lists
417
+Interactive lists allow you to present customers with a list of options.
418
+
419
+Example:
420
+```php
421
+<?php
422
+require '/usr/src/app/vendor/autoload.php';
423
+use Plivo\RestClient;
424
+
425
+$client = new RestClient("<auth_id>","<auth_token>");
426
+
427
+$interactive = '{
428
+        "type": "list",
429
+        "header": {
430
+            "type": "text",
431
+            "text": "Welcome to Plivo"
432
+        },
433
+        "body": {
434
+            "text": "You can review the list of rewards we offer"
435
+        },
436
+        "footer": {
437
+            "text": "Yours Truly"
438
+        },
439
+        "action": {
440
+            "buttons": [{
441
+                "title": "Click here"
442
+            }],
443
+            "sections": [
444
+                {
445
+                    "title": "SECTION_1_TITLE",
446
+                    "rows": [
447
+                        {
448
+                            "id": "SECTION_1_ROW_1_ID",
449
+                            "title": "SECTION_1_ROW_1_TITLE",
450
+                            "description": "SECTION_1_ROW_1_DESCRIPTION"
451
+                        },
452
+                        {
453
+                            "id": "SECTION_1_ROW_2_ID",
454
+                            "title": "SECTION_1_ROW_2_TITLE",
455
+                            "description": "SECTION_1_ROW_2_DESCRIPTION"
456
+                        }
457
+                    ]
458
+                },
459
+                {
460
+                    "title": "SECTION_2_TITLE",
461
+                    "rows": [
462
+                        {
463
+                            "id": "SECTION_2_ROW_1_ID",
464
+                            "title": "SECTION_2_ROW_1_TITLE",
465
+                            "description": "SECTION_2_ROW_1_DESCRIPTION"
466
+                        },
467
+                        {
468
+                            "id": "SECTION_2_ROW_2_ID",
469
+                            "title": "SECTION_2_ROW_2_TITLE",
470
+                            "description": "SECTION_2_ROW_2_DESCRIPTION"
471
+                        }
472
+                    ]
473
+                }
474
+            ]
475
+        }
476
+    }';
477
+
478
+$response = $client->messages->create(
479
+        [
480
+                "src"=> "+14156667778",
481
+                "dst"=> "+14156667777",
482
+                "type"=> "whatsapp",
483
+                "interactive"=> $interactive
484
+        ]
485
+);
486
+print_r($response);
487
+?>
488
+```
489
+
490
+#### Interactive CTA URLs
491
+CTA URL messages allow you to send links and call-to-action buttons.
492
+
493
+Example:
494
+```php
495
+<?php
496
+require '/usr/src/app/vendor/autoload.php';
497
+use Plivo\RestClient;
498
+
499
+$client = new RestClient("<auth_id>","<auth_token>");
500
+
501
+$interactive = '{
502
+      "type": "cta_url",
503
+        "header": {
504
+            "type": "media",
505
+            "media": "https://xyz.com/s3/img.jpg"
506
+        },
507
+        "body": {
508
+            "text": "Know More"
509
+        },
510
+        "footer": {
511
+            "text": "Plivo"
512
+        },
513
+        "action": {
514
+            "buttons": [
515
+                {
516
+                    "title": "Click here",
517
+                    "cta_url": "https:plivo.com"
518
+                }
519
+            ]
520
+        }
521
+    }';
522
+
523
+$response = $client->messages->create([
524
+        "src"=> "+14156667778",
525
+        "dst"=> "+14156667777",
526
+        "type"=> "whatsapp",
527
+        "interactive"=> $interactive
528
+]);
529
+print_r($response);
530
+?>
531
+```
532
+
533
+### Location Messages
534
+This guide shows how to send templated and non-templated location messages to recipients using Plivo’s APIs.
535
+
536
+#### Templated Location Messages
537
+Example:
538
+```php
539
+<?php
540
+require '/usr/src/app/vendor/autoload.php';
541
+use Plivo\RestClient;
542
+
543
+$client = new RestClient("<auth_id>","<auth_token>");
544
+
545
+$template = '{
546
+        "name": "plivo_order_pickup",
547
+        "language": "en_US",
548
+        "components": [
549
+            {
550
+                "type": "header",
551
+                "parameters": [
552
+                    {
553
+                        "type": "location",
554
+                        "location": {
555
+                            "longitude": "122.148981",
556
+                            "latitude": "37.483307",
557
+                            "name": "Pablo Morales",
558
+                            "address": "1 Hacker Way, Menlo Park, CA 94025"
559
+                        }
560
+                    }
561
+                ]
562
+            }
563
+        ]
564
+    }';
565
+
566
+$response = $client->messages->create([
567
+        "src"=> "+14156667778",
568
+        "dst"=> "+14156667777",
569
+        "type"=> "whatsapp",
570
+        "template"=> $template
571
+]);
572
+print_r($response);
573
+?>
574
+```
575
+
576
+#### Non-Templated Location Messages
577
+Example:
578
+```php
579
+<?php
580
+require '/usr/src/app/vendor/autoload.php';
581
+use Plivo\RestClient;
582
+
583
+$client = new RestClient("<auth_id>","<auth_token>");
584
+
585
+$location = '{
586
+        "longitude": "122.148981",
587
+        "latitude": "37.483307",
588
+        "name": "Pablo Morales",
589
+        "address": "1 Hacker Way, Menlo Park, CA 94025"
590
+    }';
591
+
592
+$response = $client->messages->create([
593
+        "src"=> "+14156667778",
594
+        "dst"=> "+14156667777",
595
+        "type"=> "whatsapp",
596
+        "location"=> $location
597
+]);
598
+print_r($response);
599
+?>
600
+```
601
+
602
+### More examples
603
+More examples are available [here](https://github.com/plivo/plivo-examples-php). Also refer to the [guides for configuring the PHP laravel to run various scenarios](https://www.plivo.com/docs/sms/quickstart/php-laravel/) & use it to test out your integration in under 5 minutes.
604
+
605
+## Reporting issues
606
+Report any feedback or problems with this version by [opening an issue on Github](https://github.com/plivo/plivo-php/issues).
607
+
608
+## Local Development
609
+> Note: Requires latest versions of Docker & Docker-Compose. If you're on MacOS, ensure Docker Desktop is running.
610
+1. Export the following environment variables in your host machine:
611
+```bash
612
+export PLIVO_AUTH_ID=<your_auth_id>
613
+export PLIVO_AUTH_TOKEN=<your_auth_token>
614
+export PLIVO_API_DEV_HOST=<plivoapi_dev_endpoint>
615
+export PLIVO_API_PROD_HOST=<plivoapi_public_endpoint>
616
+```
617
+2. Run `make build`. This will create a docker container in which the sdk will be setup and dependencies will be installed.
618
+> The entrypoint of the docker container will be the `setup_sdk.sh` script. The script will handle all the necessary changes required for local development.
619
+3. The above command will print the docker container id (and instructions to connect to it) to stdout.
620
+4. The testing code can be added to `<sdk_dir_path>/php-sdk-test/test.php` in host  
621
+ (or `/usr/src/app/php-sdk-test/test.php` in container)
622
+5. The sdk directory will be mounted as a volume in the container. So any changes in the sdk code will also be reflected inside the container.
623
+> To use the local code in the test file, import the sdk in test file using:   
624
+`require /usr/src/app/vendor/autoload.php`   
625
+(Local sdk code will be mounted at `/usr/src/app` inside the container and `vendor` directory will be created by setup script while installing dependencies).
626
+6. To run test code, run `make run CONTAINER=<cont_id>` in host.
627
+7. To run unit tests, run `make test CONTAINER=<cont_id>` in host.
628
+> `<cont_id>` is the docker container id created in 2.
629
+(The docker container should be running)
630
+
631
+> Test code and unit tests can also be run within the container using
632
+`make run` and `make test` respectively. (`CONTAINER` argument should be omitted when running from the container)
0 633
\ No newline at end of file
Browse code

removed appinfo/info.xml appinfo/signature.json CHANGELOG.txt lib/AppInfo/Application.php css/style.css providers/Plivo

DoubleBastionAdmin authored on 05/11/2025 13:12:22
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,226 +0,0 @@
1
-# plivo-php
2
-
3
-[![Build Status](https://travis-ci.org/plivo/plivo-php.svg?branch=master)](https://travis-ci.org/plivo/plivo-php)
4
-
5
-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.
6
-
7
-**Supported PHP Versions**: This SDK works with PHP 7.1.0+.
8
-
9
-## Installation
10
-
11
-### To install Composer
12
-#### Globally in Mac
13
-
14
-1. Download the latest version of [Composer](https://getcomposer.org/download/). 
15
-2. Run the following command in Terminal: 
16
-        
17
-        $ php ~/Downloads/composer.phar --version
18
-
19
-3. Run the following command to make it executable:
20
-        
21
-        $ cp ~/Downloads/composer.phar /usr/local/bin/composer
22
-        $ sudo chmod +x /usr/local/bin/composer
23
-        $ Make sure you move the file to bin directory.
24
-
25
-4. To check if the path has **/usr/local/bin**, use 
26
-        
27
-        $ echo $PATH
28
-
29
-   If the path is different, use the following command to update the $PATH:    
30
-            
31
-        $ export PATH = $PATH:/usr/local/bin
32
-        $ source ~/.bash_profile 
33
-
34
-4. You can also check the version of Composer by running the following command:
35
-        
36
-        $ composer --version.       
37
-
38
-#### Globally in Linux
39
-
40
-1. Run the following command:
41
-        
42
-        $ curl -sS https://getcomposer.org/installer | php
43
-
44
-2. Run the following command to make the composer.phar file as executable:
45
-        
46
-        $ chmod +x composer.phar
47
-
48
-3. Run the following command to make Composer globally available for all system users:
49
-        
50
-        $ mv composer.phar /usr/local/bin/composer
51
-
52
-#### Windows 10
53
-
54
-1. Download and run the [Windows Installer](https://getcomposer.org/download/) for Composer.
55
-
56
-    **Note:** Make sure to allow Windows Installer for Composer to make changes to your **php.ini** file.
57
-
58
-2. If you have any terminal windows open, close all instances and open a fresh terminal instance.
59
-3. Run the Composer command.
60
-        
61
-        $ composer -V
62
-
63
-### Steps to install Plivo Package
64
-
65
-- To install the **stable release**, run the following command in the project directory:
66
-        
67
-        $ composer require plivo/plivo-php
68
-
69
-- To install a **specific release**, run the following command in the project directory:
70
-        
71
-        $ composer require plivo/plivo-php:4.14.0
72
-
73
-- To test the features in the **beta release**, run the following command in the project directory:
74
-        
75
-        $ composer require plivo/plivo-php:v4.2-beta1
76
-
77
-- Alternatively, you can download this source and run
78
-        
79
-        $ composer install
80
-
81
-This generates the autoload files, which you can include using the following line in your PHP source code to start using the SDK.
82
-
83
-```php
84
-<?php
85
-require 'vendor/autoload.php'
86
-```
87
-
88
-## Getting started
89
-
90
-### Authentication
91
-
92
-To make the API requests, you need to create a `RestClient` and provide it with authentication credentials (which can be found at [https://manage.plivo.com/dashboard/](https://manage.plivo.com/dashboard/)).
93
-
94
-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:
95
-
96
-```php
97
-<?php
98
-require 'vendor/autoload.php';
99
-use Plivo\RestClient;
100
-
101
-$client = new RestClient();
102
-```
103
-
104
-Alternatively, you can specifiy the authentication credentials while initializing the `RestClient`.
105
-
106
-```php
107
-<?php
108
-require 'vendor/autoload.php';
109
-use Plivo\RestClient;
110
-
111
-$client = new RestClient("your_auth_id", "your_auth_token");
112
-```
113
-
114
-## The Basics
115
-The SDK uses consistent interfaces to create, retrieve, update, delete and list resources. The pattern followed is as follows:
116
-
117
-```php
118
-<?php
119
-$client->resources->create($params) # Create
120
-$client->resources->get($id) # Get
121
-$client->resources->update($id, $params) # Update
122
-$client->resources->delete($id) # Delete
123
-$client->resources->list() # List all resources, max 20 at a time
124
-```
125
-
126
-You can also use the `resource` directly to update and delete it. For example,
127
-
128
-```php
129
-<?php
130
-$resource = $client->resources->get($id)
131
-$resource->update($params) # update the resource
132
-$resource->delete() # Delete the resource
133
-```
134
-
135
-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.
136
-
137
-## Examples
138
-
139
-### Send a message
140
-
141
-```php
142
-<?php
143
-require 'vendor/autoload.php';
144
-use Plivo\RestClient;
145
-
146
-$client = new RestClient();
147
-$message_created = $client->messages->create(
148
-    'the_source_number',
149
-    ['the_destination_number'],
150
-    'Hello, world!'
151
-);
152
-```
153
-
154
-### Make a call
155
-
156
-```php
157
-<?php
158
-require 'vendor/autoload.php';
159
-use Plivo\RestClient;
160
-
161
-$client = new RestClient();
162
-$call_made = $client->calls->create(
163
-    'the_source_number',
164
-    ['the_destination_number'],
165
-    'https://answer.url'
166
-);
167
-```
168
-
169
-### Lookup a number
170
-
171
-```php
172
-<?php
173
-require 'vendor/autoload.php';
174
-use Plivo\RestClient;
175
-
176
-$client = new RestClient("AUTH_ID", "AUTH_TOKEN");
177
-$response = $client->lookup->get("<number-goes-here>");
178
-```
179
-
180
-### Generate Plivo XML
181
-
182
-```php
183
-<?php
184
-require 'vendor/autoload.php';
185
-use Plivo\XML\Response;
186
-
187
-$response = new Response();
188
-$response->addSpeak('Hello, world!');
189
-echo($response->toXML());
190
-```
191
-
192
-This generates the following XML:
193
-
194
-```xml
195
-<?xml version="1.0" encoding="utf-8"?>
196
-<Response>
197
-  <Speak>Hello, world!</Speak>
198
-</Response>
199
-```
200
-
201
-### Run a PHLO
202
-
203
-```php
204
-<?php
205
-/**
206
- * Example for API Request
207
- */
208
-require 'vendor/autoload.php';
209
-use Plivo\Resources\PHLO\PhloRestClient;
210
-use Plivo\Exceptions\PlivoRestException;
211
-$client = new PhloRestClient("YOUR_AUTH_ID", "YOUR_AUTH_TOKEN");
212
-$phlo = $client->phlo->get("YOUR_PHLO_ID");
213
-try {
214
-    $response = $phlo->run(["field1" => "value1", "field2" => "value2"]); // These are the fields entered in the PHLO console
215
-    print_r($response);
216
-} catch (PlivoRestException $ex) {
217
-    print_r($ex);
218
-}
219
-?>
220
-```
221
-
222
-### More examples
223
-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.
224
-
225
-## Reporting issues
226
-Report any feedback or problems with this version by [opening an issue on Github](https://github.com/plivo/plivo-php/issues).
Browse code

Added README.md appinfo/info.xml appinfo/signature.json lib/Controller/AuthorApiController.php and the providers directory

DoubleBastionAdmin authored on 20/08/2022 16:33:00
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,226 @@
1
+# plivo-php
2
+
3
+[![Build Status](https://travis-ci.org/plivo/plivo-php.svg?branch=master)](https://travis-ci.org/plivo/plivo-php)
4
+
5
+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.
6
+
7
+**Supported PHP Versions**: This SDK works with PHP 7.1.0+.
8
+
9
+## Installation
10
+
11
+### To install Composer
12
+#### Globally in Mac
13
+
14
+1. Download the latest version of [Composer](https://getcomposer.org/download/). 
15
+2. Run the following command in Terminal: 
16
+        
17
+        $ php ~/Downloads/composer.phar --version
18
+
19
+3. Run the following command to make it executable:
20
+        
21
+        $ cp ~/Downloads/composer.phar /usr/local/bin/composer
22
+        $ sudo chmod +x /usr/local/bin/composer
23
+        $ Make sure you move the file to bin directory.
24
+
25
+4. To check if the path has **/usr/local/bin**, use 
26
+        
27
+        $ echo $PATH
28
+
29
+   If the path is different, use the following command to update the $PATH:    
30
+            
31
+        $ export PATH = $PATH:/usr/local/bin
32
+        $ source ~/.bash_profile 
33
+
34
+4. You can also check the version of Composer by running the following command:
35
+        
36
+        $ composer --version.       
37
+
38
+#### Globally in Linux
39
+
40
+1. Run the following command:
41
+        
42
+        $ curl -sS https://getcomposer.org/installer | php
43
+
44
+2. Run the following command to make the composer.phar file as executable:
45
+        
46
+        $ chmod +x composer.phar
47
+
48
+3. Run the following command to make Composer globally available for all system users:
49
+        
50
+        $ mv composer.phar /usr/local/bin/composer
51
+
52
+#### Windows 10
53
+
54
+1. Download and run the [Windows Installer](https://getcomposer.org/download/) for Composer.
55
+
56
+    **Note:** Make sure to allow Windows Installer for Composer to make changes to your **php.ini** file.
57
+
58
+2. If you have any terminal windows open, close all instances and open a fresh terminal instance.
59
+3. Run the Composer command.
60
+        
61
+        $ composer -V
62
+
63
+### Steps to install Plivo Package
64
+
65
+- To install the **stable release**, run the following command in the project directory:
66
+        
67
+        $ composer require plivo/plivo-php
68
+
69
+- To install a **specific release**, run the following command in the project directory:
70
+        
71
+        $ composer require plivo/plivo-php:4.14.0
72
+
73
+- To test the features in the **beta release**, run the following command in the project directory:
74
+        
75
+        $ composer require plivo/plivo-php:v4.2-beta1
76
+
77
+- Alternatively, you can download this source and run
78
+        
79
+        $ composer install
80
+
81
+This generates the autoload files, which you can include using the following line in your PHP source code to start using the SDK.
82
+
83
+```php
84
+<?php
85
+require 'vendor/autoload.php'
86
+```
87
+
88
+## Getting started
89
+
90
+### Authentication
91
+
92
+To make the API requests, you need to create a `RestClient` and provide it with authentication credentials (which can be found at [https://manage.plivo.com/dashboard/](https://manage.plivo.com/dashboard/)).
93
+
94
+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:
95
+
96
+```php
97
+<?php
98
+require 'vendor/autoload.php';
99
+use Plivo\RestClient;
100
+
101
+$client = new RestClient();
102
+```
103
+
104
+Alternatively, you can specifiy the authentication credentials while initializing the `RestClient`.
105
+
106
+```php
107
+<?php
108
+require 'vendor/autoload.php';
109
+use Plivo\RestClient;
110
+
111
+$client = new RestClient("your_auth_id", "your_auth_token");
112
+```
113
+
114
+## The Basics
115
+The SDK uses consistent interfaces to create, retrieve, update, delete and list resources. The pattern followed is as follows:
116
+
117
+```php
118
+<?php
119
+$client->resources->create($params) # Create
120
+$client->resources->get($id) # Get
121
+$client->resources->update($id, $params) # Update
122
+$client->resources->delete($id) # Delete
123
+$client->resources->list() # List all resources, max 20 at a time
124
+```
125
+
126
+You can also use the `resource` directly to update and delete it. For example,
127
+
128
+```php
129
+<?php
130
+$resource = $client->resources->get($id)
131
+$resource->update($params) # update the resource
132
+$resource->delete() # Delete the resource
133
+```
134
+
135
+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.
136
+
137
+## Examples
138
+
139
+### Send a message
140
+
141
+```php
142
+<?php
143
+require 'vendor/autoload.php';
144
+use Plivo\RestClient;
145
+
146
+$client = new RestClient();
147
+$message_created = $client->messages->create(
148
+    'the_source_number',
149
+    ['the_destination_number'],
150
+    'Hello, world!'
151
+);
152
+```
153
+
154
+### Make a call
155
+
156
+```php
157
+<?php
158
+require 'vendor/autoload.php';
159
+use Plivo\RestClient;
160
+
161
+$client = new RestClient();
162
+$call_made = $client->calls->create(
163
+    'the_source_number',
164
+    ['the_destination_number'],
165
+    'https://answer.url'
166
+);
167
+```
168
+
169
+### Lookup a number
170
+
171
+```php
172
+<?php
173
+require 'vendor/autoload.php';
174
+use Plivo\RestClient;
175
+
176
+$client = new RestClient("AUTH_ID", "AUTH_TOKEN");
177
+$response = $client->lookup->get("<number-goes-here>");
178
+```
179
+
180
+### Generate Plivo XML
181
+
182
+```php
183
+<?php
184
+require 'vendor/autoload.php';
185
+use Plivo\XML\Response;
186
+
187
+$response = new Response();
188
+$response->addSpeak('Hello, world!');
189
+echo($response->toXML());
190
+```
191
+
192
+This generates the following XML:
193
+
194
+```xml
195
+<?xml version="1.0" encoding="utf-8"?>
196
+<Response>
197
+  <Speak>Hello, world!</Speak>
198
+</Response>
199
+```
200
+
201
+### Run a PHLO
202
+
203
+```php
204
+<?php
205
+/**
206
+ * Example for API Request
207
+ */
208
+require 'vendor/autoload.php';
209
+use Plivo\Resources\PHLO\PhloRestClient;
210
+use Plivo\Exceptions\PlivoRestException;
211
+$client = new PhloRestClient("YOUR_AUTH_ID", "YOUR_AUTH_TOKEN");
212
+$phlo = $client->phlo->get("YOUR_PHLO_ID");
213
+try {
214
+    $response = $phlo->run(["field1" => "value1", "field2" => "value2"]); // These are the fields entered in the PHLO console
215
+    print_r($response);
216
+} catch (PlivoRestException $ex) {
217
+    print_r($ex);
218
+}
219
+?>
220
+```
221
+
222
+### More examples
223
+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.
224
+
225
+## Reporting issues
226
+Report any feedback or problems with this version by [opening an issue on Github](https://github.com/plivo/plivo-php/issues).