当前位置:网站首页>Curlpost PHP
Curlpost PHP
2022-07-06 00:36:00 【Owenzhang24】
/** * AdoptionCURLEnvoyerHTTPDemande * * @param string $url //DemandeURL * @param array $postFields //Paramètres de demande * @return mixed * */function curlPost($url, $data = null){// if (is_array($data)) {// $data = http_build_query($data);// } $data = json_encode($data); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json; charset=utf-8' //jsonVersion à remplir Content-Type: application/json; ) ); curl_setopt($ch, CURLOPT_HEADER, false);//Ne pas retourner les informations d'en - tête curl_setopt($ch, CURLOPT_POST, 1); if ($data != null) { curl_setopt($ch, CURLOPT_POSTFIELDS, $data); } curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Les résultats sont - ils affichés? ,1Ne pas afficher,0Afficher //Déterminer sihttps if (strpos($url, 'https://') !== false) { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $UserAgent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 3.5.21022; .NET CLR 1.0.3705; .NET CLR 1.1.4322)'; curl_setopt($ch, CURLOPT_USERAGENT, $UserAgent); } $data = curl_exec($ch); curl_close($ch); if ($data === FALSE) { $data = ['code' => 400, 'msg' => curl_error($ch)]; } return ['code' => 200, 'data' => json_decode($data, true)];}边栏推荐
- [QT] QT uses qjson to generate JSON files and save them
- Idea remotely submits spark tasks to the yarn cluster
- 【线上小工具】开发过程中会用到的线上小工具合集
- 剖面测量之提取剖面数据
- Opencv classic 100 questions
- Ffmpeg learning - core module
- Global and Chinese market of digital serial inverter 2022-2028: Research Report on technology, participants, trends, market size and share
- Cloud guide DNS, knowledge popularization and classroom notes
- Pointer - character pointer
- anconda下载+添加清华+tensorflow 安装+No module named ‘tensorflow‘+KernelRestarter: restart failed,内核重启失败
猜你喜欢
![Go learning --- structure to map[string]interface{}](/img/e3/59caa3f2ba5bd3647bdbba075ee60d.jpg)
Go learning --- structure to map[string]interface{}

Spark SQL空值Null,NaN判断和处理

MySQL functions

MySql——CRUD
![Atcoder beginer contest 254 [VP record]](/img/13/656468eb76bb8b6ea3b6465a56031d.png)
Atcoder beginer contest 254 [VP record]

AtCoder Beginner Contest 254【VP记录】

FFT learning notes (I think it is detailed)

Model analysis of establishment time and holding time

AtCoder Beginner Contest 258【比赛记录】

常用API类及异常体系
随机推荐
Reading notes of the beauty of programming
【DesignMode】适配器模式(adapter pattern)
Global and Chinese markets for hinged watertight doors 2022-2028: Research Report on technology, participants, trends, market size and share
notepad++正则表达式替换字符串
Spark-SQL UDF函数
Basic introduction and source code analysis of webrtc threads
Meta AI西雅图研究负责人Luke Zettlemoyer | 万亿参数后,大模型会持续增长吗?
AtCoder Beginner Contest 254【VP记录】
Yolov5, pychar, Anaconda environment installation
Key structure of ffmpeg - avformatcontext
[groovy] JSON string deserialization (use jsonslurper to deserialize JSON strings | construct related classes according to the map set)
MySql——CRUD
Folding and sinking sand -- weekly record of ETF
【DesignMode】装饰者模式(Decorator pattern)
Go learning - dependency injection
How to solve the problems caused by the import process of ecology9.0
《编程之美》读书笔记
FFmpeg抓取RTSP图像进行图像分析
Pointer pointer array, array pointer
Multithreading and high concurrency (8) -- summarize AQS shared lock from countdownlatch (punch in for the third anniversary)