当前位置:网站首页>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)];}
边栏推荐
- AtCoder Beginner Contest 258【比赛记录】
- Knowledge about the memory size occupied by the structure
- LeetCode 6004. Get operands of 0
- Ffmpeg captures RTSP images for image analysis
- Spark DF adds a column
- OS i/o devices and device controllers
- XML配置文件
- Multithreading and high concurrency (8) -- summarize AQS shared lock from countdownlatch (punch in for the third anniversary)
- 【EI会议分享】2022年第三届智能制造与自动化前沿国际会议(CFIMA 2022)
- synchronized 和 ReentrantLock
猜你喜欢
MIT博士论文 | 使用神经符号学习的鲁棒可靠智能系统
Browser local storage
Arduino六足机器人
图解网络:TCP三次握手背后的原理,为啥两次握手不可以?
Hudi of data Lake (2): Hudi compilation
Multithreading and high concurrency (8) -- summarize AQS shared lock from countdownlatch (punch in for the third anniversary)
Spark AQE
Ffmpeg captures RTSP images for image analysis
STM32 configuration after chip replacement and possible errors
Go learning --- structure to map[string]interface{}
随机推荐
Idea remotely submits spark tasks to the yarn cluster
devkit入门
Browser local storage
【线上小工具】开发过程中会用到的线上小工具合集
NLP text processing: lemma [English] [put the deformation of various types of words into one form] [wet- > go; are- > be]
Spark AQE
SQLServer连接数据库读取中文乱码问题解决
[Chongqing Guangdong education] reference materials for Zhengzhou Vocational College of finance, taxation and finance to play around the E-era
Set data real-time update during MDK debug
Spark获取DataFrame中列的方式--col,$,column,apply
MySQL functions
MIT博士论文 | 使用神经符号学习的鲁棒可靠智能系统
Spark SQL null value, Nan judgment and processing
7.5 decorator
uniapp开发,打包成H5部署到服务器
Cloud guide DNS, knowledge popularization and classroom notes
Browser reflow and redraw
Location based mobile terminal network video exploration app system documents + foreign language translation and original text + guidance records (8 weeks) + PPT + review + project source code
云导DNS和知识科普以及课堂笔记
[QT] QT uses qjson to generate JSON files and save them