|
Posted by Henk Oegema on 04/19/07 09:34
Dear forum.
I'm trying to get a (test) script working which would log me in to
VoipBuster and then send a SMS to my mobile phone.
When it is working this script will be used in my Asterisk PBX to send
automatically a SMS message, with the message that telephone number xxxxxx
has called me.
This function is discussed in forum
http://forum.asteriskportal.nl/index.php?topic=288.msg1772#msg1772
(unfortunately (for this forum) in the Dutch language)
To test the script I put in a browser the following address:
http://localhost/sms/sms.php?number=00324763788xx&msg=This is a test
File /srv/www/htdocs/sms/sms.php (SuSE10.2):
=================================
<?php
function encryptString($string)
{
for ($i=0;$i<strlen($string);$i++)
{
$chr = $string{$i};
if ($chr == "0")
{
$chr = "5";
$string{$i} = $chr;
}
elseif ($chr == "1")
{
$chr = "6";
$string{$i} = $chr;
}
elseif ($chr == "2")
{
$chr = "7";
$string{$i} = $chr;
}
elseif ($chr == "3")
{
$chr = "8";
$string{$i} = $chr;
}
elseif ($chr == "4")
{
$chr = "9";
$string{$i} = $chr;
}
elseif ($chr == "5")
{
$chr = "0";
$string{$i} = $chr;
}
elseif ($chr == "6")
{
$chr = "1";
$string{$i} = $chr;
}
elseif ($chr == "7")
{
$chr = "2";
$string{$i} = $chr;
}
elseif ($chr == "8")
{
$chr = "3";
$string{$i} = $chr;
}
elseif ($chr == "9")
{
$chr = "4";
$string{$i} = $chr;
}
}
return str_rot13($string);
}
// Set username and password
$username = encryptString('henkoegema');
$password = encryptString('my_voipbuster_password');
$URL =
('https://myaccount.voipbuster.com/clx/index.php?part=plogin&username=' .
$username . '&password=' . $password);
// Get number and message
$number =($_GET['number']);
$msg =($_GET['msg']);
// INIT CURL
$ch = curl_init();
// SET URL FOR THE POST FORM LOGIN
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
// IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES
curl_setopt ($ch, CURLOPT_COOKIEJAR, '/tmp/cookie.txt');
# Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
# not to print out the results of its query.
# Instead, it will return the results as a string return value
# from curl_exec() instead of the usual true/false.
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
// EXECUTE 1st REQUEST (FORM LOGIN)
$store = curl_exec ($ch);
// SET Message
curl_setopt($ch,
CURLOPT_URL, 'https://myaccount.voipbuster.com/clx/websms.php');
// ENABLE HTTP POST
curl_setopt ($ch, CURLOPT_POST, 1);
// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'message=' .
$msg . '&bnrphonenumber=' . $number . '&submit=Send&action=send');
// EXECUTE 2nd REQUEST (Send Message)
$content = curl_exec ($ch);
// CLOSE CURL
curl_close ($ch);
//debug
//print $content;
?>
===================================end sms.php =========================
This script works with other people.
With me, the script seems to stop at the line:
// INIT CURL
$ch = curl_init();
When I add the line
print("this is a test line");
//INIT CURL
print("this is a testline");
$ch=curl_init();
than I get output of the print statement
If I move the line as follows (or lower in the file):
//INIT CURL
$ch=curl_init();
print("this is a test line");
then I get NO print output
I'm using php version 5.2.0-10
Other people (were the scripts works) use php version 4.3.2
Could this be the reason that I can't get it working?
Or is there any mistake in my script ?
Gr. Henk
Navigation:
[Reply to this message]
|