Example api code for Promotional SMS in php

Replace user, password, msisdn, sid and message accordingly.

 

1. Below is the sample code for php for Single Message:

<?php
$user = 'abc';
$password = 'xyz';
$msisdn = '919898xxxxxx';
$sid = 'SenderId';
$message = 'test message';
$fl = '0';

$url = 'http://sms.domainadda.com/vendorsms/pushsms.aspx?user=' . $user . '&password=' . $password . '&msisdn=' . $msisdn . '&sid=' . $sid . '&msg=' . urlencode($message) . '&fl=' . $fl;

$response = file_get_contents($url);

if ($response === false) {
echo 'Error sending request';
} else {
echo 'API response: ' . $response;
}
?>

 

2. Below is the sample code for php for Multiple Messages:

<?php
$user = 'abc';
$password = 'xyz';
$msisdns = '919898xxxxxx,919898xxxxxx'; // Comma-separated list of phone numbers
$sid = 'SenderId';
$message = 'test message';
$fl = '0';

$url = 'http://sms.domainadda.com/vendorsms/pushsms.aspx';
$params = array(
'user' => $user,
'password' => $password,
'msisdn' => $msisdns,
'sid' => $sid,
'msg' => $message,
'fl' => $fl,
);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

if ($response === false) {
echo 'Error sending request: ' . curl_error($ch);
} else {
echo 'API response: ' . $response;
}

curl_close($ch);
?>

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Example api code for Promotional SMS in asp.net

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...

Example api code for Promotional SMS in java

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...

Example api code for Promotional SMS in ruby

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...

Example api code for Promotional SMS in node,js

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...

Example api code for Promotional SMS in python

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...