Page 1 of 1

Help with curl script.

Posted: Thu Jun 11, 2015 8:57 am
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;
    }

Re: Help with curl script.

Posted: Thu Jun 11, 2015 9:36 am
by Celauran
What sort of errors are you encountering?