curl_init()

返回一个 curl handle

curl_setopt()

为curl handle设置参数,格式为 curlopt_xxx
常用参数:

  • curlopt_url:url

  • curlopt_referer:referer提交的页面

  • curlopt_post:是否是post请求

  • curlopt_timeout:超时时间

  • curlopt_httpheader:head请求数据

  • curlopt_header:

  • curlopt_ssl_verifypeer:false to stop curl from verifying the peer’s certificate. alternate certificates to verify against can be specified with the curlopt_cainfo option or a certificate directory can be specified with the curlopt_capath option.

  • curlopt_ssl_verifyhost:1 to check the existence of a common name in the ssl peer certificate. 2 to check the existence of a common name and also verify that it matches the hostname provided. 0 to not check the names. in production environments the value of this option should be kept at 2 (default value).

  • curlopt_returntransfer:true to return the transfer as a string of the return value of curl_exec() instead of outputting it directly.

  • curlopt_postfields:post提交数据

curl_exec()

执行请求,如果设置了 curlopt_returntransfer,成功会返回结果,失败返回false。

curl_close()

关闭