[solved][example] How to 'send from file' using command line/from user application

We have user who want to send from file feature directly from command line or their application instead using the portal. How can we achieved this using the playsms feature i.e to call directly from user application system.

You can use webservices with a script that parse the numbers and messages from a file

Thanks all. I managed to solved this based on Anton & Syed info on his webpages. Below is my soln which maybe useful for others.

  1. Below is the PHP script to be executed from user side. i call it sendBulkSMS.php and use a tab delimited test file named testdata.txt in with the contents format as follow;


9898989<tab>message 1 to send
7865678<tab>message 2 to send
telnoN<tab>message N to send

User side sendBulkSMS.php

    $target_url = 'http://server-ip-or-domain/sendBulkSMS.asp';
//  This filename needs to be the full path to the file you want to send. e.g testdata.txt
//  In this sample data it is tab separated: mobilenumber <tab> message-to-send
    $file_name_with_full_path = realpath('/datafile/testdata.txt'); 
	$username = 'tester';                           // change to your playsms userid
	$password = '684df1a1426a06e7626d22d878352f65'; // use yr webservice token 
	$dt = date("Y-m-d-H:i:s");						// current date for filename-tag
	$remotefile = $username.'-bulksms-'.$dt;        // bulksms file will be stored with userid at the server
                                             	   	// userid-bulksms-9999-99-99-99:99:99
    $post = array('userid' => $username, 'password'=> $password, 'file' => new CurlFile($file_name_with_full_path, 'text/plain', $remotefile));
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$target_url);
    curl_setopt($ch, CURLOPT_POST,1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    $result=curl_exec ($ch);
    curl_close ($ch);
    echo $result;
  1. Below is the sendBulkSMS.php to be stored at playsms server
<?php $username = $_POST['userid']; $token = $_POST['password']; // Store the uploaded file for future audit or reference $uploaddir = realpath('/var/log/bulksmsfromfile') . '/';

if (isset($_FILES[‘file’]))
$uploadfile = $uploaddir . basename($_FILES[‘file’][‘name’]);
if (move_uploaded_file($_FILES[‘file’][‘tmp_name’], $uploadfile)) {
echo “Bulk SMS File was successfully uploaded for User:”.$username." \n";
} else {
echo “Possible file upload attack!\n”;

// SMS Webservices URL
$qgsmsx_ws = ‘http://server-ip-or-domainname/index.php?app=ws’;
$file= file_get_contents($uploadfile);
$array1= explode(“
$smsdetail= explode(“\t”,$array1[$i]);
$destinations = $smsdetail[0];
$message = $smsdetail[1];
// send sms using WEBSERVICES HTTP API
if ($message) {
$ws = $qgsmsx_ws . ‘&u=’ . $username . ‘&h=’ . $token . ‘&op=pv’;
$ws .= ‘&to=’ . urlencode($destinations) . ‘&msg=’.urlencode($message) . ‘&nofooter=1’;
$ret = @file_get_contents($ws);
echo $ret;
echo “OK: message sent” . PHP_EOL;
} else {
echo " " . PHP_EOL;

echo "Bulk SMS Sending Completed";

// end processing the file

Hope this helps others who may need it. Cheers!