简体   繁体   中英

I can't connect to server using curl

When I try to send request to the server in localhost I receive this message :

Error: call to URL https://wasl.elm.sa/WaslPortalWeb/rest/DriverRegistration/send failed with status 200, response {"resultCode":503,"resultMessage":"Yakeen Failure: The ID Is Not Found at NIC","referenceNumber":0,"valid":false}, curl_error , curl_errno 0

On the live server I receive this message :

string(171) "{"apiKey":"My api key","captainIdentityNumber":"12355567897","dateOfBirth":"15-07-1400","emailAddress":"mo@mo.com","mobileNumber":"966508060095"}" Error: call to URL https://wasl.elm.sa/WaslPortalWeb/rest/DriverRegistration/send failed with status 0, response , curl_error Unknown SSL protocol error in connection to wasl.elm.sa:443 , curl_errno 35

I use this script to make the request:

<?php

    //driver registartion url   
    $url = "https://wasl.elm.sa/WaslPortalWeb/rest/DriverRegistration/send";     
    $data=["apiKey"=>"My apikey","captainIdentityNumber"=>"1234567897","dateOfBirth"=>"15-07-1400","emailAddress"=>"mo@mo.com","mobileNumber"=>"966508060095"];
    $content = json_encode($data);
    $curl = curl_init($url);

    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $content);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_HEADER,false);
    curl_setopt($curl, CURLOPT_HTTPHEADER,array("Content-type: application/json"));
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    var_dump($content);
    $json_response = curl_exec($curl);
    $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    if ( $status != 201 ) {
        die("Error: call to URL $url failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));
    }
    curl_close($curl);
    $response = json_decode($json_response, true);
    var_dump($response);
    ?>

my api key it's correct one given by the server owner

This is related to Wasl portal, it is not related to curl or connection errors.

You have to contact the portal admins because it is API specific error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM