Dismiss Notice
We would like to remind you that we’re updating our login process for all 3CX forums whereby you will be able to login with the same credentials you use for the Partner or Customer Portal. Click here to read more.

VoipBuster / Voipcheap .API

Discussion in '3CX Phone System - General' started by jvwelzen, Aug 21, 2008.

Thread Status:
Not open for further replies.
  1. jvwelzen

    Joined:
    Jun 9, 2008
    Messages:
    8
    Likes Received:
    0
    I found an .api for voipbuster on the astriks forum

    I was wondering if it is possible to use it with 3cx below is the scipt

    on astriks you can call 301 for example en then hear your balance of your voipbuster account

    here is the script

    <?php
    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($login);
    $password = encryptString($pass);



    $LOGINURL = ('https://myaccount.voipcheap.com/clx/index.php?part=plogin&username=' . $username . '&password=' . $password);
    $CREDITURL = 'https://myaccount.voipcheap.com/clx/buy_credit.php';
    $user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"; // <- nieuw!!!!

    //curl init
    $ch = curl_init();
    // SET 1st REQUEST
    curl_setopt($ch, CURLOPT_URL, $LOGINURL);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); // <-nieuw!!!!
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    //curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); // <- nieuw!!!!
    //curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies);
    curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/cookie.txt');


    // EXECUTE 1st REQUEST (FORM LOGIN)
    $store = curl_exec ($ch);
    //echo $store; //Only for debug

    // SET 2nd REQUEST
    curl_setopt($ch, CURLOPT_URL, $CREDITURL);

    // EXECUTE 2nd REQUEST (CREDITURL)
    $content = curl_exec ($ch);

    // CLOSE CURL
    curl_close ($ch);

    //echo $content; //Only for debug
    //we gaan eventjes knippen in de ruwe source code van de returnwaarde
    //bestudeer de html source en alles wordt duidelijk
    $start = strpos($content,'balanceid'); //bepaal start van balanceid
    $start1 = strpos($content,'Freedays remaining:'); //bepaal start van balanceid
    $deelstring = substr($content,$start+14,26); //kopieer het begin van het bedrag de string naar een tussen waarde
    $deelstring1 = substr($content,$start1+26,10); //kopieer het begin van het bedrag de string naar een tussen waarde
    //print $deelstring; //Only for debug
    $einde = strpos($deelstring,'<'); //einde van het bedrag is waar de afsluit tag begint
    $einde1 = strpos($deelstring1,'<'); //einde van het bedrag is waar de afsluit tag begint
    $bedrag = substr($deelstring,0,$einde);
    $bedrag1 = substr($deelstring1,0,$einde1);
    //echo "$content";


    print $bedrag;
    echo " Euro ";
    echo "<br><br>";
    If ($bedrag1 == NULL){
    echo '0';
    echo " Dagen ";
    } else {
    print $bedrag1;
    echo " Dagen ";
    }

    ?>
     
  2. francesco

    francesco New Member

    Joined:
    Jun 23, 2008
    Messages:
    102
    Likes Received:
    0
    for me, 3cx don't permit to call a script
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Thread Status:
Not open for further replies.