<?php// 返回JSONheader("Content-type:application/json");// 初始化 CURL$ch = curl_init();// 服务器URLcurl_setopt($ch, CURLOPT_URL,'服务器URL');curl_setopt($ch, CURLOPT_POST, true);// 设置参数$data = array(array('aaa' => 'aaa','bbb' => 'bbb'));curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));// 对认证证书来源的检查curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);// 从证书中检查SSL加密算法是否存在curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);// 获取的信息以文件流的形式返回,而不是直接输出curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);// 请求头$headers[] = "content-type:multipart/form-data;"; // content-type$headers[] = "user-agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3947.100 Safari/537.36"; // user-agent$headers[] = "cookie:xxx"; // cookiecurl_setopt($ch, CURLOPT_HTTPHEADER,$headers);// 发起请求并返回请求结果$result = curl_exec($ch);// 关闭请求curl_close($ch);?>
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号