当前位置:网站首页>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)];}边栏推荐
- MySQL functions
- Global and Chinese markets of universal milling machines 2022-2028: Research Report on technology, participants, trends, market size and share
- Spark SQL null value, Nan judgment and processing
- 小程序技术优势与产业互联网相结合的分析
- LeetCode 6006. Take out the least number of magic beans
- Codeforces round 804 (Div. 2) [competition record]
- How to make your own robot
- Data analysis thinking analysis methods and business knowledge - analysis methods (III)
- LeetCode 1189. Maximum number of "balloons"
- JS can really prohibit constant modification this time!
猜你喜欢

小程序技术优势与产业互联网相结合的分析

Spark AQE

Intranet Security Learning (V) -- domain horizontal: SPN & RDP & Cobalt strike
![[groovy] JSON string deserialization (use jsonslurper to deserialize JSON strings | construct related classes according to the map set)](/img/bf/18ef41a8f30523b7ce57d03f93892f.jpg)
[groovy] JSON string deserialization (use jsonslurper to deserialize JSON strings | construct related classes according to the map set)

XML配置文件

Key structure of ffmpeg -- AVCodecContext

Free chat robot API

Start from the bottom structure and learn the introduction of fpga---fifo IP core and its key parameters

MySQL存储引擎

Arduino六足机器人
随机推荐
AtCoder Beginner Contest 258【比赛记录】
LeetCode 6004. Get operands of 0
Leetcode Fibonacci sequence
Global and Chinese market of digital serial inverter 2022-2028: Research Report on technology, participants, trends, market size and share
Yolov5, pychar, Anaconda environment installation
LeetCode 1598. Folder operation log collector
《强化学习周刊》第52期:Depth-CUPRL、DistSPECTRL & Double Deep Q-Network
Data analysis thinking analysis methods and business knowledge - analysis methods (III)
Model analysis of establishment time and holding time
Single source shortest path exercise (I)
About the slmgr command
Mysql - CRUD
Notepad + + regular expression replace String
Global and Chinese market of water heater expansion tank 2022-2028: Research Report on technology, participants, trends, market size and share
Basic introduction and source code analysis of webrtc threads
从 1.5 开始搭建一个微服务框架——调用链追踪 traceId
Determinant learning notes (I)
Ffmpeg learning - core module
Spark SQL UDF function
Common API classes and exception systems