msg91 php code

Solutions on MaxInterview for msg91 php code by the best coders in the world

showing results for - "msg91 php code"
Rebeca
18 May 2020
1<?php
2
3//Your authentication key
4$authKey = "YourAuthKey";
5
6//Multiple mobiles numbers separated by comma
7$mobileNumber = "9999999";
8
9//Sender ID,While using route4 sender id should be 6 characters long.
10$senderId = "102234";
11
12//Your message to send, Add URL encoding here.
13$message = urlencode("Test message");
14
15//Define route 
16$route = "default";
17//Prepare you post parameters
18$postData = array(
19    'authkey' => $authKey,
20    'mobiles' => $mobileNumber,
21    'message' => $message,
22    'sender' => $senderId,
23    'route' => $route
24);
25
26//API URL
27$url="http://api.msg91.com/api/sendhttp.php";
28
29// init the resource
30$ch = curl_init();
31curl_setopt_array($ch, array(
32    CURLOPT_URL => $url,
33    CURLOPT_RETURNTRANSFER => true,
34    CURLOPT_POST => true,
35    CURLOPT_POSTFIELDS => $postData
36    //,CURLOPT_FOLLOWLOCATION => true
37));
38
39
40//Ignore SSL certificate verification
41curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
42curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
43
44
45//get response
46$output = curl_exec($ch);
47
48//Print error if any
49if(curl_errno($ch))
50{
51    echo 'error:' . curl_error($ch);
52}
53
54curl_close($ch);
55
56echo $output;
57?>
similar questions
queries leading to this page
msg91 php code