Help with curl script.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Bigster
Forum Newbie
Posts: 1
Joined: Thu Jun 11, 2015 8:43 am

Help with curl script.

Post by Bigster »

Hello,

Need help with following script. Wish to create a form with sends serial and user details to following script and get registered.

Code: Select all

   /**
     * Create a call via CURL with BASIC AUTH
     */
    function curlWebserviceCall($sServiceUrl)
    {
        $curl = curl_init($sServiceUrl);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
        curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
        curl_setopt($curl, CURLOPT_USERPWD, "your_email:your_password");
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($curl, CURLOPT_HEADER, FALSE);

        $curl_response = curl_exec($curl);
        $oResponse = json_decode($curl_response);

        curl_close($curl);
        return $oResponse;
    }

    // YOUR DATA
    $sSerial    = 'THE_SERIAL';
    $iPartnerId = 'your UVI partner id';
    $sUserIlok  = 'the user ilok';
    $sUserEmail = 'the user email';
    // url creation
    $sCallUrl = 'https://webservices.uvi.net/partner/register'
              . '?serial=' . urlencode(trim($sSerial))
              . '&partner_id=' . intval($iPartnerId)
              . '&user_ilok=' . urlencode(trim($sUserIlok))
              . '&user_email=' . urlencode(trim($sUserEmail));
    // make the webservice call
    $oResult        = curlWebserviceCall($sCallUrl);
    $sReturnStatus  = $oResult->return;
    // print the return info to your user (or else)
    if($sReturnStatus === 'success') {
        // success, you can print the info for example
        echo $oResult->info;
    } else {
        // failure, you can advertise your user
        echo $oResult->info;
    }
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Help with curl script.

Post by Celauran »

What sort of errors are you encountering?
Post Reply