当前位置:网站首页>Leaky API interface practical development series (13): gooseneck cloud service php-api two-dimensional array parameter transfer solution
Leaky API interface practical development series (13): gooseneck cloud service php-api two-dimensional array parameter transfer solution
2022-06-25 23:29:00 【Missed engraving sometimes】
Using the gosling cloud service API Development process , When passing a two-dimensional array , Always prompt in the background The user id list must be an array. That is, the passed parameter must be an array .
Document request standard format
{
"access_token": "xxxxxxxx",
"user_id_list": [
"u_xxxx",
"u_xxxx",
"u_xxxx"
],
"page": 1,
"page_size": 3
}
among "user_id_list" It's a two-dimensional array .
PHP Reference page
require_once __DIR__ . '/libs/Client.php';
$client = new Client();
$url = "https://api.xiaoe-tech.com/xe.user.batch_by_user_id.get/1.0.0";
$method = "post";
// Gets individual user information ;
$page_size = $_GET['page_size'];
if ($page_size == "") {
$page_size = 10;
}
$user_id_list = ['u_62b29be26704d_0cjjzuCSNk', '"u_62b2c2c2a121f_uFYhvzwnUP'];
$params = ['user_id_list' => $user_id_list, 'page' => 1, 'page_size' => $page_size];
$result = $client->request($method, $url, $params);
die(json_encode($result));
Return content
{
"req_msg":"The user id list must be an array.",
"req_code":8
}
Error page
Mocha ITOM – Request log :
Solution
take
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
It is amended as follows
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postdata));
http_build_query() Is to convert an array to url question mark ? The following parameter string , And it will be done automatically urlencode Handle .

@lockdata.cn
边栏推荐
- LM小型可编程控制器软件(基于CoDeSys)笔记十七:pto脉冲功能块
- Oracle - getting started
- Fastjson deserialization randomness failed
- The applet draws a simple pie chart
- 剑指 Offer 46. 把数字翻译成字符串(DP)
- Multithreaded learning 2- call control
- Network security project questions of the first Henan vocational skills competition in 2022
- String deformation (string case switching and realization)
- Why is BeanUtils not recommended?
- 电路模块分析练习6(开关)
猜你喜欢

漏刻有时API接口实战开发系列(13):小鹅通云服务PHP-API二维数组传参解决方案

How to use JMeter for interface testing

论文笔记: 多标签学习 MSWL

CTS RTS RX TX in serial port flow control UART (direct communication between serial port module and MCU)

建立自己的网站(15)

Oracle -- table operation

String deformation (string case switching and realization)

【ModuleBuilder】GP服务实现SDE中两个图层相交选取

一位博士在华为的22年

百度:2022年十大热度攀升专业出炉,第一名无悬念!
随机推荐
Repoptimizer: it's actually repvgg2
Live800在线客服系统:跨越时空做生意,从每次互动开始
Svn icon disappearing solution
【opencv450-samples】inpaint 使用区域邻域恢复图像中的选定区域
pdm的皮毛
Day3 data types and operators summary and job
UE4 学习记录二 给角色添加骨架,皮肤,及运动动画
Unity technical manual - life cycle rotation rotationoverlifetime- speed rotation rotationbyspeed- and external forces
Applets - view and logic
最近准备翻译外国优质文章
[modulebuilder] GP service realizes the intersection selection of two layers in SDE
Xampp重启后,MySQL服务就启动不了。
22 years of a doctor in Huawei
Oracle -- table operation
How to use drawing comparison function in CAD
STM32开发板+机智云AIoT+家庭监测控制系统
一位博士在华为的22年
Efr32bg22 ble module (low power Bluetooth communication module) at command test
[2023 proofreading and bidding questions] Part 1: Measurement Technology FPGA post (roughly analytical version)
LM small programmable controller software (based on CoDeSys) note XVII: PTO pulse function block