当前位置:网站首页>php的curl函数模拟post数据提交,速度非常慢
php的curl函数模拟post数据提交,速度非常慢
2022-08-02 03:26:00 【陌潇】
前段时间做了一个项目,里面用到了快递查询接口。用的php 的curl post请求,发现此请求非常慢,效率非常低,就很恼火。还以为是快递接口那边的问题,试了下快递自己的请求非常快。于是研究了一波发现了一个解决办法,记录一下:
原本的请求是这样的,效率非常慢
//发送post请求
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
$data = json_decode($result,true);
这样就得添加curl请求参数了:
- 强制协议为1.0
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
- 强制使用IPV4协议解析域名
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
完满解决问题
边栏推荐
- 学IT,找工作——反转链表
- The CTF introductory notes of SQL injection
- 学IT,找工作——移除链表元素
- 英语每日打卡
- hackmyvm-hopper预排
- 库存现金、现金管理制度、现金的账务处理、银行存款、银行存款的账务处理、银行存款的核对
- ES6 array extension methods map, filter, reduce, fill and array traversal for…in for…of arr.forEach
- Turn trendsoft/capital amount of Chinese capital library
- A code audit notes (CVE - 2018-12613 phpmyadmin file contains loopholes)
- CTF-Neting Cup Past Topics
猜你喜欢

CTF入门之php文件包含

redis未授权访问(4-unacc)

DNS详解

不懂“赚钱逻辑”,你永远都是社会最底层(广告电商)

The CTF introduction of PHP file contains

hackmyvm-hopper预排

uniapp | Compilation error after updating with npm update

成本会计的概念、产品成本核算的要求、产品成本核算的对象与成本项目、产品成本的归集和分配(可能考判断)、产品成本计算方法 (三种:产品的品种(品种法),批次(分批法),步骤(分步法))

What are the killer super powerful frameworks or libraries or applications for PHP?

2021-09-04 最简单的Golang定时器应用以及最简单的协程入门儿
随机推荐
The CTF introduction of PHP file contains
By figure, a (complete code at the end)
动力:2 vulnhub预排
xxe of CTF
Shuriken: 1 vulnhub walkthrough
(1) print()函数、转义字符、二进制与字符编码 、变量、数据类型、input()函数、运算符
CSRF (Cross Site Request Forgery)
PHP realizes the automatic reverse search prompt of the search box
利用cookie获取admin权限 CTF基础题
Alibaba Cloud MySQL 5.7 installation and some major problems (total)
(4) 函数、Bug、类与对象、封装、继承、多态、拷贝
学IT,找工作——移除链表元素
Cookie is used to collect the admin privileges CTF foundation problem
Sensitive information leakage
库存现金、现金管理制度、现金的账务处理、银行存款、银行存款的账务处理、银行存款的核对
链动2+1模式开发系统
Basic use of v-on, parameter passing, modifiers
一个网络安全小白鼠的学习之路—nmap高级用法之脚本使用
File upload vulnerability
Scrapy crawler encounters redirection 301/302 problem solution