当前位置:网站首页>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)];}边栏推荐
- How to solve the problems caused by the import process of ecology9.0
- Codeforces round 804 (Div. 2) [competition record]
- [EI conference sharing] the Third International Conference on intelligent manufacturing and automation frontier in 2022 (cfima 2022)
- OS i/o devices and device controllers
- MySql——CRUD
- SQLServer连接数据库读取中文乱码问题解决
- Atcoder beginer contest 254 [VP record]
- Spark SQL UDF function
- Data analysis thinking analysis methods and business knowledge -- analysis methods (II)
- MIT博士论文 | 使用神经符号学习的鲁棒可靠智能系统
猜你喜欢

State mode design procedure: Heroes in the game can rest, defend, attack normally and attack skills according to different physical strength values.

Browser local storage
![Atcoder beginer contest 258 [competition record]](/img/e4/1d34410f79851a7a81dd8f4a0b54bf.gif)
Atcoder beginer contest 258 [competition record]

Ffmpeg captures RTSP images for image analysis

Intranet Security Learning (V) -- domain horizontal: SPN & RDP & Cobalt strike

MySQL存储引擎

【DesignMode】装饰者模式(Decorator pattern)

LeetCode 1189. Maximum number of "balloons"

【EI会议分享】2022年第三届智能制造与自动化前沿国际会议(CFIMA 2022)

猿桌派第三季开播在即,打开出海浪潮下的开发者新视野
随机推荐
[designmode] Decorator Pattern
Data analysis thinking analysis methods and business knowledge -- analysis methods (II)
Natural language processing (NLP) - third party Library (Toolkit):allenlp [library for building various NLP models; based on pytorch]
Mysql - CRUD
Browser local storage
Gd32f4xx UIP protocol stack migration record
Global and Chinese markets for pressure and temperature sensors 2022-2028: Research Report on technology, participants, trends, market size and share
[simple implementation of file IO]
Spark AQE
CTF daily question day44 rot
图解网络:TCP三次握手背后的原理,为啥两次握手不可以?
Model analysis of establishment time and holding time
[groovy] JSON string deserialization (use jsonslurper to deserialize JSON strings | construct related classes according to the map set)
notepad++正則錶達式替換字符串
Power Query数据格式的转换、拆分合并提取、删除重复项、删除错误、转置与反转、透视和逆透视
如何解决ecology9.0执行导入流程流程产生的问题
Atcoder beginer contest 258 [competition record]
Spark SQL null value, Nan judgment and processing
What is information security? What is included? What is the difference with network security?
Go learning - dependency injection