当前位置:网站首页>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)];}
边栏推荐
- XML配置文件
- 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
- Extracting profile data from profile measurement
- Anconda download + add Tsinghua +tensorflow installation +no module named 'tensorflow' +kernelrestart: restart failed, kernel restart failed
- Problems and solutions of converting date into specified string in date class
- STM32 key chattering elimination - entry state machine thinking
- Spark SQL空值Null,NaN判断和处理
- 《强化学习周刊》第52期:Depth-CUPRL、DistSPECTRL & Double Deep Q-Network
- Browser reflow and redraw
- Go learning - dependency injection
猜你喜欢
OpenCV经典100题
MYSQL GROUP_ The concat function realizes the content merging of the same ID
Problems and solutions of converting date into specified string in date class
LeetCode 1189. Maximum number of "balloons"
Room cannot create an SQLite connection to verify the queries
Multithreading and high concurrency (8) -- summarize AQS shared lock from countdownlatch (punch in for the third anniversary)
Model analysis of establishment time and holding time
Leetcode:20220213 week race (less bugs, top 10% 555)
[designmode] composite mode
Spark SQL空值Null,NaN判断和处理
随机推荐
NLP basic task word segmentation third party Library: ICTCLAS [the third party library with the highest accuracy of Chinese word segmentation] [Chinese Academy of Sciences] [charge]
OpenCV经典100题
详细页返回列表保留原来滚动条所在位置
Analysis of the combination of small program technology advantages and industrial Internet
STM32按键消抖——入门状态机思维
Spark SQL空值Null,NaN判断和处理
Solve the problem of reading Chinese garbled code in sqlserver connection database
Data analysis thinking analysis methods and business knowledge - analysis methods (III)
常用API类及异常体系
LeetCode 1189. Maximum number of "balloons"
Determinant learning notes (I)
Data analysis thinking analysis methods and business knowledge -- analysis methods (II)
【EI会议分享】2022年第三届智能制造与自动化前沿国际会议(CFIMA 2022)
剖面测量之提取剖面数据
[groovy] JSON string deserialization (use jsonslurper to deserialize JSON strings | construct related classes according to the map set)
猿桌派第三季开播在即,打开出海浪潮下的开发者新视野
Hudi of data Lake (2): Hudi compilation
Leetcode 450 deleting nodes in a binary search tree
[Chongqing Guangdong education] Chongqing Engineering Vocational and Technical College
如何解决ecology9.0执行导入流程流程产生的问题