You are here: Voipbuster PHP script not working (anymore) « All PHP « IT news, forums, messages
Voipbuster PHP script not working (anymore)

Posted by Henk Oegema on 06/12/07 21:58

I'm using the script below to get the remaining balance of my VoipBuster
account.
I'm using this script in my Astrerisk PBX server.

==========================begin script =======================

function encryptString($string) {
for($i=0; $i < strlen($string); $i++) {
if(is_numeric($string[$i])) {
if($string[$i] < "5")
$string[$i]= $string[$i] + 5;
else
$string[$i]= $string[$i] - 5;
}
}
return str_rot13($string);
}

// Set username and password:
$username = encryptString('your_own_voipbusterusername');
$password = encryptString('your_own_voipbusterpassword');

$loginurl=
('https://myaccount.voipbuster.com/clx/index.php?part=plogin&username=' .
$username . '&password=' . $password);
$mainmenuurl =
('https://myaccount.voipbuster.com/clx/index.php?part=menu&justloggedin=true');

//========== FIRST PART (LOGIN): ==========================

$cookiejar = tempnam("", "");
if ($cookiejar) {
$ch = curl_init(); // curl initialization

curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiejar); //connecting cookie input
and output to
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar); //this curl session

curl_setopt ($ch, CURLOPT_URL, $loginurl); //set URL to use in GET/POST
action

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); //return received data
(instead of curl result code)

curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); //DISABLE HTTPS
AUTHENTICATION CHECKING:

curl_exec ($ch); //EXECUTE 1st REQUEST (FORM LOGIN):
//will give a redirect to: /index.php?part=menu&justloggedin=true


//========== SECOND PART: ==========

// FOLLOWING REDIRECT TO /index.php?....:
curl_setopt($ch, CURLOPT_URL, $mainmenuurl);

$content = curl_exec ($ch); //EXECUTE 2nd REQUEST (load 'main menu'),
saving data in $content:

curl_close ($ch); //close curl session


$start = strpos($content,'balanceid'); //bepaal start van balanceid
$deelstring = substr($content,$start+26,10); //kopieer het begin van het
bedrag de string naar een tussen waarde
//print $deelstring;
$einde = strpos($deelstring,'<'); //einde van het bedrag is waar de
afsluit tag begint
$bedrag = substr($deelstring,0,$einde);
print "Remaining credit: $bedrag\n"; //use this for testing
// print "$bedrag"; //gebruik dit als je het als AGI script gaat gebruiken
in Asterisk

}
else { print "error creating cookie file"; }

?>

==========================end script ===============================

Here is where I use the script in my Asterisk server:

exten=>3002,1,Answer()
exten=>3002,2,Set(status=${CURL(http://localhost/credit/credit_voipbuster.php)})
exten=>3002,3,NoOP(${status})
exten=>3002,4,SayDigits(${status})
exten=>3002,5,Playback(vm-goodbye)
exten=>3002,6,Hangup()


When I dial extension 3002, I will here the remaining balance.

I have been using this script without any problems.
However................after a new installation of Linux (SuSE102.2) and a
new installation of Asterisk, the result is always 0.

This line :

exten=>3002,2,Set(status=${CURL(http://localhost/credit/credit_voipbuster.php)})

should assign the value of the remaining balance to the variable 'status'.
It contains only the value 0, instead of the real balance.

If I run the script directly from a web browser, it prints the RIGHT value
(print "Remaining credit: $bedrag\n"; //use this for testing)

The funny thing is that the script worked correctly before I did a new
installation.
(I jus copied the old file to the new installation)

Somebody who can help? ::)

Rgds
Henk

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация