当前位置:Gxlcms > PHP教程 > PHP调用http接口

PHP调用http接口

时间:2021-07-01 10:21:17 帮助过:3人阅读

  1. //http请求接口
  2. function curl_http_request($param,$url)
  3. {
  4. $ch = curl_init();
  5. $curl_url = $url."?".$param;
  6. curl_setopt($ch, CURLOPT_URL, $curl_url);
  7. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); //禁用证书
  8. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  9. curl_setopt ($ch, CURLOPT_HEADER, 0); //头文件信息做数据流输出
  10. curl_setopt($ch, CURLOPT_POST, 1);
  11. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//不直接输出,返回到变量
  12. $curl_result = curl_exec($ch);
  13. curl_close($ch);
  14. return $curl_result;
  15. }

PHP, http

人气教程排行