当前位置:网站首页>PHP curl function
PHP curl function
2022-06-12 10:20:00 【Qu Shuai 369】
function http_request($url, $data = null, $headers = array())
{
$curl = curl_init();
if (count($headers) >= 1) {
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
}
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
if (!empty($data)) {
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($curl);
curl_close($curl);
return $output;
}
$url = 'http://fusion.qiniuapi.com?param=abc';
$headers = array('Content-Type: application/json','token: 123456');
$data = ['name'=>'xiaoming','age'=>18];
http_request($url, $data, $headers)
边栏推荐
- 原始套接字使用
- Getting started with cloud API basics -- basic knowledge of picgo writing plug-ins
- 93. obtain all IP addresses of the Intranet
- Auto. JS learning note 10: instantiate a custom object and use json The stringify() method causes an error (resolved)
- 2021-09-13
- Circuitbreaker fuse of resilience4j - circuitbreakerevent event
- Introduction to IOT
- PostgreSQL uses stored procedures to splice multiple tables and query data
- [DDS] dds-rpc implementation based on opendds
- [MySQL] index invalidation and index optimization
猜你喜欢

机器学习不是你想用,想用就能用

JVM (V) Virtual machine class loading (parental delegation mechanism)

Halcon combined with C # to detect surface defects -- affine transformation (III)

Research on autojs wechat: the control IP in wechat on different versions of wechat or simulators is different.

Add jar package under idea2018 web project

MySQL III Configuration file & log file

Auto. JS learning note 4: after autojs is packaged, most Huawei and other big brand mobile phones cannot be installed? This problem can be solved by using the simulator to remotely sign and package in

MYSQL的最左匹配原则的原理讲解

properties中文乱码

Chapter 3 search
随机推荐
C 语言仅凭自学能到什么高度?
HALCON联合C#检测表面缺陷——仿射变换(三)
Auto. JS learning notes 5:ui interface foundation of autojs Chapter 1
Explication du principe d'appariement le plus à gauche de MySQL
How PLC constructs shift function block (FC) by itself
conda 安装tensorflow 测试tensorflow
OpenCV中CLAHE用于16位图像增强显示
Introduction to on-line circuit simulation and open source electronic hardware design
[926. flip the string to monotonic increment]
验收标准到底是不是测试用例?
Introduction to IOT
Create simple windowing programs using Visual Studio 2017
redis学习记录:字典(dict)源码分析
原始套接字使用
[Wayland] Weston multi screen display
2021-09-15
Spark complex structure data retrieval method
Data processing and visualization of machine learning [iris data classification | feature attribute comparison]
Auto. JS learning note 9: basic methods such as using the script engine, starting the script file with the specified path, and closing
QT custom window fillets