Shock: curl returns a status code turned out to be so !!!

curl_exec curl request returns false, curl_error return empty

提交数据到https时,需要pem证书来加密。

我们使用浏览器访问https的时候,浏览器会自动加载网站的安全证书进行加密。但是你用curl请求https时,没有通过浏览器,就只有自己手动增加一个安全证书进行加密。
    $curl=curl_init();
    curl_setopt ( $curl, CURLOPT_URL, $url);
    curl_setopt ( $curl, CURLOPT_POST, 1 );
    curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, 1 );
    curl_setopt ( $curl, CURLOPT_POSTFIELDS, $data );
    curl_setopt ( $curl, CURLOPT_TIMEOUT, 2);   
    // 为保证服务器之间数据传输的安全性,所有的https方式调用,必须使用下面2行代码打开ssl安全校验。
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);

    $value = curl_exec($curl);
    curl_close($curl);

So you can get to the

`0` normal access

`1` wrong protocol is not supported by the protocol. This version cURL does not support this agreement.

2 `` failed initialization code initialization failed.

3` URL incorrectly formatted `URL is malformed. Syntax is incorrect.

4 `` request protocol error

5 `` can not resolve the proxy agent can not resolve. Unable to resolve a given proxy host.

6 `` can not resolve the host address can not resolve the host. Unable to resolve the given remote host.

7 'Unable to connect to host `can not connect to the host.

8` remote server is not abnormal response by `FTP server. cURL can not parse the data sent by the server.

9 `` FTP access to a resource error Access is denied. The server refuses to sign or can not obtain a particular resource or directory you want. Most likely you are attempting to enter a directory on the server does not exist.

11` FTP password error `FTP abnormal PASS reply. cURL can not be resolved to send a response to the request of the PASS.

13 'erroneous results `FTP unusual in PASV response, cURL can not be resolved to send a response to the PASV request.

14` FTP command `FTP PASV response to abnormal 227 format. cURL can not resolve 227 lines sent by the server.

15 'internal fault `FTP can not connect to the host. Unable to resolve host IP acquired in the 227 line.

17 'is set to binary `FTP transfer mode can not be set to binary transmission. You can not change the transmission mode to binary.

File transfer 18` `short or greater than the expected part of the file. Only part of the file is transmitted.

19` RETR command transfer is complete `FTP can not download / access a given file, RETR (or similar) command failed.

21 `` FTP quote command completed successfully error. quote command returns an error from the server.

22` return to normal `HTTP page not found. The requested URL could not find or return another 400 or more errors HTTP. This return code only appears in the use of the -f / - fail option in the future.

23 '' written data write failure error. cURL can not write to the local file system, or similar purposes.

25 `` FTP upload not start not STOR file. Server rejected the STOR operation for FTP upload.

26 'callback error `read error. Read all kinds of problems.

27 'memory allocation request fails `out of memory. Memory allocation request fails.

`28` access timeout operation timed out. Arrived at the designated time-out period conditions.

30` FTP port error `FTP PORT failed. PORT command failed. Not all servers support FTP PORT command, try using (PASV) transfer instead of passive!

31` FTP error `FTP REST command can not be used. REST command failed. This command is used to recover FTP transfers.

33 'does not support the request `HTTP range error. range "command" does not work.

34` internal error occurred `HTTP POST error. POST requests internal error.

35` SSL / TLS handshake failure `SSL connection errors. SSL handshake failed.

36` download can not be recovered `FTP resume damaged. Earlier this download can not continue to be suspended.

`37` file permission error file can not be read. Unable to open file. Permissions issue?

38` LDAP can be non-binding `LDAP not binding. LDAP bind (bind) operation failed.

39` LDAP search fails `LDAP search fails.

41 'function does not find `function can not be found. LDAP can not find the necessary functions.

42 'abort callback `terminated by the callback. Application informed cURL terminate the operation.

43 'Internal Error' internal error. It made an incorrect parameter to call the function.

`45` Interface error interface error. Specified outgoing interface could not be used.

47` too many redirects `too many redirects. cURL reached the maximum limit set by following the redirect with

48 'does not recognize the option `An unknown TELNET options.

`49` TELNET malformed malformed telnet options.

`Peer SSL certificate SSL certificate of the remote server 51 'of the MD5 or SSH fingerprint is not OK.

52 'server returns nothing `server without any response, the case is considered to be a mistake here.

`53` encryption engine is not found can not find the SSL encryption engine.

54` set the default SSL encryption fails `SSL encryption engine can not be set as the default.

`55` not send network data network to send data failed.

Receiving network data `56` failure failed in the receiving network data.

57`
     
58` local client certificate `local certificate in question.

`59` can not use a password can not be used to specify the SSL password.

60 'credentials could not be verified `peer certificate can not be known CA certificate validation.

61` Unrecognized transfer encoding `Unrecognized transfer encoding.

62` invalid LDAP URL` invalid LDAP URL.

`63` file exceeds the maximum size exceeds the maximum file size.

64` FTP SSL level `Fail Fail requirements of FTP.

`65` rewinding operation failed rewinding transmitting the data required (rewind) fails.

`66` SSL engine failed to initialize SSL engine failure.

`67` server rejects the login user name, password or similar information is not accepted, cURL login fails.

68` file not found 'file not found on the TFTP server.

69` no authority `TFTP server permissions problem.

70 'beyond the `TFTP server server disk space is insufficient disk space.

71 'illegal' illegal operation TFTP TFTP operation.

72 'ID` unknown unknown TFTP transfer TFTP transfer number (ID).

`73` file already exists file already exists (TFTP).

74` `No such user error TFTP server (TFTP).

75` character conversion fails `character conversion failed.

76 'callback' needs must be recorded character conversion function.

77` CA certificate authority `read SSL certificate problems (path? Access rights?).

78` URL referenced in the resources do not exist `URL referenced resource does not exist.

79` error occurred during the SSH session `SSH session An unknown error occurred.

80 '' can not close the SSL connection fails to shut down the SSL connection.

81` service is not ready

82 'Could not load file' can not load CRL CRL file is missing or incorrectly formatted (increase in version 7.19.0 in).

`83` issuer check fails to issue the check fails (the increase in version 7.19.0).
 

Guess you like

Origin blog.csdn.net/weixin_39616995/article/details/87873444