-
Notifications
You must be signed in to change notification settings - Fork 2
/
example.php
79 lines (51 loc) · 1.8 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/* Send an SMS using Cyn SMS. You can run this file 3 different ways:
*
* 1. Save it as example.php and at the command line, run
* php example.php
*
* 2. Upload it to a web host and load mywebhost.com/example.php
* in a web browser.
*
* 3. Download a local server like WAMP, MAMP or XAMPP. Point the web root
* directory to the folder containing this file, and load
* localhost:8888/example.php in a web browser.
*/
// Step 1: Get the Cyn SMS API library from https://github.com/cynojine/cynsms-api,
// following the instructions to install it with Composer.
require_once 'src/Class_Cyn_SMS_API.php';
use CynSMS\CynSMSAPI;
// Step 2: set your API_KEY from https://sms.cynojine.com/sms-api/info
$api_key = 'YWRtaW46YWRtaW4ucGFzc3dvcmQ=';
// Step 3: Change the from number below. It can be a valid phone number or a String
$from = 'Cynojine';
// Step 4: the number we are sending to - Any phone number
$destination = '260965858668';
// <sms/api> is mandatory.
$url = 'https://sms.cynojine.com/sms/api';
// the sms body
$sms = 'test message from Cyn SMS';
// unicode sms
$unicode = 0; //For Plain Message
$unicode = 1; //For Unicode Message
// Create SMS Body for request
$sms_body = array(
'api_key' => $api_key,
'to' => $destination,
'from' => $from,
'sms' => $sms,
'unicode' => $unicode,
);
// Step 6: instantiate a new Cyn SMS API request
$client = new CynSMSAPI();
// Step 7: Send SMS
$response = $client->send_sms($sms_body, $url);
print_r($response);
// Step 8: Get Response
$response=json_decode($response);
// Display a confirmation message on the screen
echo 'Message: '.$response->message;
//Step 9: Get your inbox
$get_inbox=$client->get_inbox($api_key,$url);
//Step 10: Get your account balance
$check_balance=$client->check_balance($api_key,$url);