Home > Backend Development > PHP Tutorial > PHP curl get post

PHP curl get post

WBOY
Release: 2016-06-20 12:29:19
Original
909 people have browsed it

public function httpGet($url=""){			    $curl = curl_init();	    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);	    curl_setopt($curl, CURLOPT_TIMEOUT, 500);	    // 为保证第三方服务器与微信服务器之间数据传输的安全性,所有微信接口采用https方式调用,必须使用下面2行代码打开ssl安全校验。	    // 如果在部署过程中代码在此处验证失败,请到 http://curl.haxx.se/ca/cacert.pem 下载新的证书判别文件。	    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);	    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);	    curl_setopt($curl, CURLOPT_URL, $url);	    $res = curl_exec($curl);	    curl_close($curl);	    return $res;	}	public function httpPost($url="" ,$requestData=array()){						$curl = curl_init();		curl_setopt($curl, CURLOPT_URL, $url);		curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);		curl_setopt($curl, CURLOPT_POSTFIELDS, $requestData);				$res = curl_exec($curl);		curl_close($curl);				return $res;	}
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template