|
1 |
| -# JustSend API |
2 |
| -SMS PHP Api justsend. |
| 1 | +# JustSend REST API PHP |
| 2 | +Justsend rest php api. How to send sms message from php rest api (single and multiple messages). |
3 | 3 |
|
4 |
| -### Jak wysłać wiadomość do kilku odbiorców |
5 |
| -Klasa klienta w php do wysyłki wiadomości sms. |
| 4 | +### Send sms to single recipient |
6 | 5 | ```php
|
7 |
| -<?php |
8 |
| -// Show errors |
9 |
| -ini_set('display_errors', 1); |
10 |
| -ini_set('display_startup_errors', 1); |
11 |
| -error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING); |
| 6 | +try |
| 7 | +{ |
| 8 | + $curl = new JustSendClient(); |
| 9 | + $curl->SetMethod("POST"); |
| 10 | + $curl->SetJson(); |
12 | 11 |
|
| 12 | + // Token |
| 13 | + $curl->AddToken('API-KEY-HERE'); |
| 14 | + |
| 15 | + // Single number |
| 16 | + $curl->AddUrl('https://justsend.pl/api/rest/v2/message/send'); |
| 17 | + |
| 18 | + // Mesage |
| 19 | + $curl->AddData("bulkVariant","ECO"); // ECO, PRO, FULL |
| 20 | + $curl->AddData("doubleEncode", true); |
| 21 | + $curl->AddData("from", "HellGirl"); |
| 22 | + $curl->AddData("message", "Testowa wiadomość"); |
| 23 | + $curl->AddData("to", "500111222"); |
| 24 | + |
| 25 | + // Send |
| 26 | + echo $curl->Send(); |
| 27 | +} |
| 28 | +catch(Exception $e) |
| 29 | +{ |
| 30 | + print_r($e); |
| 31 | +} |
| 32 | +``` |
| 33 | + |
| 34 | +### Send sms to multiple recipients |
| 35 | +```php |
| 36 | +<?php |
13 | 37 | // Import client
|
14 | 38 | require('JustSendClient.php');
|
15 | 39 |
|
|
50 | 74 | }
|
51 | 75 | ```
|
52 | 76 |
|
53 |
| -### Jak wysłać wiadomość do jednego odbiorcy |
| 77 | +### Display php errors |
54 | 78 | ```php
|
55 |
| -try |
56 |
| -{ |
57 |
| - $curl = new JustSendClient(); |
58 |
| - $curl->SetMethod("POST"); |
59 |
| - $curl->SetJson(); |
60 |
| - |
61 |
| - // Token |
62 |
| - $curl->AddToken('API-KEY-HERE'); |
63 |
| - |
64 |
| - // Lub dla pojedyńczego odbiorcy |
65 |
| - $curl->AddUrl('https://justsend.pl/api/rest/v2/message/send'); |
66 |
| - |
67 |
| - // Wiadomość |
68 |
| - $curl->AddData("bulkVariant","ECO"); // ECO, PRO, FULL |
69 |
| - $curl->AddData("doubleEncode", true); |
70 |
| - $curl->AddData("from", "HellGirl"); |
71 |
| - $curl->AddData("message", "Testowa wiadomość"); |
72 |
| - $curl->AddData("to", "500111222"); |
73 |
| - |
74 |
| - // Send |
75 |
| - echo $curl->Send(); |
76 |
| -} |
77 |
| -catch(Exception $e) |
78 |
| -{ |
79 |
| - print_r($e); |
80 |
| -} |
81 |
| -``` |
| 79 | +<?php |
| 80 | +// Show errors |
| 81 | +ini_set('display_errors', 1); |
| 82 | +ini_set('display_startup_errors', 1); |
| 83 | +error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING); |
| 84 | +``` |
0 commit comments