Re: how to clear input and outbox sms? programmatically

Home Forums Re: how to clear input and outbox sms? programmatically

#3483
Christopher Rivera
Participant

Here is a copy of my code that I use. The main things to note are:

where you see the function httpPost, that is curl function that sends data to the server using a POST method, and returns the response.

where you see the function httpGett, that is curl function that sends data to the server using a GET method, and returns the response.

// START OF CODE

$user_id = ”;

$fields = array();

$fields = ‘index.html’; // the default page we want.

$fields = ‘XXXXXXXX’; // define your username

$fields = ‘XXXXXXXX’; // define your password

// CURL: Login.

// This simulates the login. ip is your ip address.

$url = ‘http://’ . $ip . ‘/cgi-bin/postquery.cgi’;

$response = httpPost($url, $fields);

// We do this call to get the user_id.

$userdata = httpGet(‘http://’ . $ip . ‘/index.html?0’);

// The data in $userdata has the value we want.

if ( preg_match(“/”([^.]+).html?(d+)”/”, $userdata, $m) )

{

// the first set of numbers that appear after the string ‘.html?’ is our user_id

$user_id = $m[2];

$str = httpGet(‘http://’ . $ip . ‘/smsSent.html?’ . $user_id);

// nothing to do.

if ( preg_match(‘/Outbox is Empty./’,$str) ) { exit(); }

// we have data.

if ( preg_match(‘/Page (d+) of (d+)/’,$str, $m) )

{

// Now we must post to the system with the commands to clear the outbox.

$max_pg_no=$m[2];

$url = ‘http://’ . $ip . ‘/cgi-bin/postquery.cgi’;

$fields = array();

$fields = ‘set cleanoutbox status enable samas’;

$fields = ‘smsSent.html’;

$fields = $user_id;

$fields = $max_pg_no;

$response = httpPost($url, $fields);

}

}

// END OF CODE

You can modify it to do some more stuff like verification of the clearing.