当前位置:网站首页>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)];}边栏推荐
- 猿桌派第三季开播在即,打开出海浪潮下的开发者新视野
- 孤勇者
- Introduction of motor
- Spark SQL空值Null,NaN判断和处理
- 小程序容器可以发挥的价值
- STM32 configuration after chip replacement and possible errors
- devkit入门
- Pointer pointer array, array pointer
- [groovy] JSON string deserialization (use jsonslurper to deserialize JSON strings | construct related classes according to the map set)
- Start from the bottom structure and learn the introduction of fpga---fifo IP core and its key parameters
猜你喜欢
随机推荐
免费的聊天机器人API
The global and Chinese markets of dial indicator calipers 2022-2028: Research Report on technology, participants, trends, market size and share
详细页返回列表保留原来滚动条所在位置
Atcoder beginer contest 254 [VP record]
About the slmgr command
AtCoder Beginner Contest 254【VP记录】
Folding and sinking sand -- weekly record of ETF
LeetCode 6006. Take out the least number of magic beans
Data analysis thinking analysis methods and business knowledge - analysis methods (III)
Codeforces round 804 (Div. 2) [competition record]
LeetCode 6005. The minimum operand to make an array an alternating array
【文件IO的简单实现】
Comment faire votre propre robot
Ffmpeg learning - core module
Anconda download + add Tsinghua +tensorflow installation +no module named 'tensorflow' +kernelrestart: restart failed, kernel restart failed
AtCoder Beginner Contest 258【比赛记录】
Recognize the small experiment of extracting and displaying Mel spectrum (observe the difference between different y_axis and x_axis)
Global and Chinese markets of universal milling machines 2022-2028: Research Report on technology, participants, trends, market size and share
What is information security? What is included? What is the difference with network security?
【DesignMode】装饰者模式(Decorator pattern)





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



