当前位置:网站首页>curlpost-php
curlpost-php
2022-07-06 00:36:00 【owenzhang24】
/** * adopt CURL send out HTTP request * * @param string $url // request URL * @param array $postFields // Request parameters * @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' //json Version needs to be filled in Content-Type: application/json; ) ); curl_setopt($ch, CURLOPT_HEADER, false);// Do not return header information curl_setopt($ch, CURLOPT_POST, 1); if ($data != null) { curl_setopt($ch, CURLOPT_POSTFIELDS, $data); } curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Whether the results are displayed ,1 No display ,0 Show // Determine whether https 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)];}边栏推荐
- Analysis of the combination of small program technology advantages and industrial Internet
- curlpost-php
- Notepad + + regular expression replace String
- Codeforces gr19 D (think more about why the first-hand value range is 100, JLS yyds)
- Global and Chinese markets for pressure and temperature sensors 2022-2028: Research Report on technology, participants, trends, market size and share
- Cloud guide DNS, knowledge popularization and classroom notes
- NLP text processing: lemma [English] [put the deformation of various types of words into one form] [wet- > go; are- > be]
- Spark DF增加一列
- Go learning --- read INI file
- 【DesignMode】适配器模式(adapter pattern)
猜你喜欢
![Atcoder beginer contest 258 [competition record]](/img/e4/1d34410f79851a7a81dd8f4a0b54bf.gif)
Atcoder beginer contest 258 [competition record]

Key structure of ffmpeg - avframe

多线程与高并发(8)—— 从CountDownLatch总结AQS共享锁(三周年打卡)

Data analysis thinking analysis methods and business knowledge - analysis methods (III)
![Atcoder beginer contest 254 [VP record]](/img/13/656468eb76bb8b6ea3b6465a56031d.png)
Atcoder beginer contest 254 [VP record]

MySql——CRUD

MySQL storage engine

Introduction of motor

How to make your own robot

【EI会议分享】2022年第三届智能制造与自动化前沿国际会议(CFIMA 2022)
随机推荐
Search (DFS and BFS)
State mode design procedure: Heroes in the game can rest, defend, attack normally and attack skills according to different physical strength values.
LeetCode 1189. Maximum number of "balloons"
如何解决ecology9.0执行导入流程流程产生的问题
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]
PHP determines whether an array contains the value of another array
Room cannot create an SQLite connection to verify the queries
Solve the problem of reading Chinese garbled code in sqlserver connection database
[groovy] JSON string deserialization (use jsonslurper to deserialize JSON strings | construct related classes according to the map set)
Anconda download + add Tsinghua +tensorflow installation +no module named 'tensorflow' +kernelrestart: restart failed, kernel restart failed
Global and Chinese markets for hinged watertight doors 2022-2028: Research Report on technology, participants, trends, market size and share
Set data real-time update during MDK debug
Go learning --- read INI file
孤勇者
OpenCV经典100题
《强化学习周刊》第52期:Depth-CUPRL、DistSPECTRL & Double Deep Q-Network
Reading notes of the beauty of programming
Gavin teacher's perception of transformer live class - rasa project actual combat e-commerce retail customer service intelligent business dialogue robot system behavior analysis and project summary (4
【EI会议分享】2022年第三届智能制造与自动化前沿国际会议(CFIMA 2022)
Single source shortest path exercise (I)