search

Home  >  Q&A  >  body text

php - win7 64-bit curl_exec($ch) returns always false

My colleagues can get normal values ​​on win10, but the return value of curl_exec($ch) on my win7 is always false. Then try to type curl_error($ch) which is a string(0) "".

I checked the local PHP configuration and curl should be enabled


I will follow suit later

http://php.net/manual/zh/curl...

The following method will
libeay32.dll
libssh2.dll
ssleay32.dll

Place these three files

C:\Program Files\Apache Software Foundation\Apache2.4\bin

In this directory, after restarting apache, the result is still false.

My php version is 5.6.23. And the code problem has been basically eliminated. I would like to ask if any of you have encountered similar situations and how you resolved them in the end. I can't thank you enough.

The following is the detailed code.

$ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    $headers=array(
        // 'W-ACCESS-TOKEN: '.$access_token,
        'Content-Type: application/json'
    );
    //add header
    curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge($headers,$app_headers));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
    // curl_setopt($ch, CURLOPT_COOKIE, implode(';', $cookies_items));
    curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);

    if($method=='PUT'){
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
    }elseif($method=='DELETE'){
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
    }
    
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;

Updated again, now the following error is reported after catching the exception

Curl failed with error #7: Failed to connect to auc.qa2.test.yiran.com port 80: Timed out


Updated on April 21
Resolved.
No host is configured. Once paired, it can be connected.

PHP中文网PHP中文网2780 days ago1269

reply all(2)I'll reply

  • 巴扎黑

    巴扎黑2017-05-16 13:13:03

    Timeout just can’t connect, try opening this url manually and see. .

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-16 13:13:03

    Post the code and check whether curl_setopt sets CURLOPT_RETURNTRANSFER to true

    reply
    0
  • Cancelreply