当前位置:网站首页>漏刻有时API接口实战开发系列(13):小鹅通云服务PHP-API二维数组传参解决方案
漏刻有时API接口实战开发系列(13):小鹅通云服务PHP-API二维数组传参解决方案
2022-06-25 21:59:00 【漏刻有时】
在使用小鹅通云服务API开发过程中,当传递二维数组时,后台总是提示The user id list must be an array.即传递的参数必须是数组。
文档请求标准格式
{
"access_token": "xxxxxxxx",
"user_id_list": [
"u_xxxx",
"u_xxxx",
"u_xxxx"
],
"page": 1,
"page_size": 3
}
其中"user_id_list"为二维数组。
PHP传参页面
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";
//获取单个用户信息;
$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));
返回内容
{
"req_msg":"The user id list must be an array.",
"req_code":8
}
错误提示页
运维管理–请求日志:
解决方案
将
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
修改为
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postdata));
http_build_query()就是将一个数组转换成url 问号?后面的参数字符串,并且会自动进行urlencode处理。

@lockdata.cn
边栏推荐
- Somme logarithmique (deux points) pour le Groupe 52 - - e de la course de la lune blanche de niuke
- Problem recording and thinking
- 【2023校招刷题】番外篇1:度量科技FPGA岗(大致解析版)
- 百度:2022年十大热度攀升专业出炉,第一名无悬念!
- Applets - view and logic
- 小程序-视图与逻辑
- Exclusive or operator simple logic operation a^=b
- Why is the frame rate calculated by opencv wrong?
- Several optimization scenarios using like fuzzy retrieval in SQL
- Svn icon disappearing solution
猜你喜欢

元宇宙标准论坛成立

ES6 -- 形参设置初始值、拓展运算符、迭代器、生成函数

Live800在线客服系统:跨越时空做生意,从每次互动开始

2022年河南省第一届职业技能大赛网络安全项目试题

Utilisation de la classe Ping d'Unity

Actual combat: how to quickly change font color in typera (blog sharing - perfect) -2022.6.25 (solved)

22 years of a doctor in Huawei

What aspects should we start with in the feasibility analysis of dry goods?

1281_FreeRTOS_vTaskDelayUntil实现分析

The applet draws a simple pie chart
随机推荐
Idea shortcut
Civil Aviation Administration: by 2025, China will initially build a safe, intelligent, efficient and green aviation logistics system
【opencv450-samples】读取图像路径列表并保持比例显示
【opencv450 samples】创建图像列表yaml
首个大众可用PyTorch版AlphaFold2复现,哥大开源OpenFold,star量破千
Which PHP open source works deserve attention
Why is BeanUtils not recommended?
ES6-- 模板字符串、对象的简化写法、箭头函数
Idea auto generator generates constructor get/set methods, etc
ES6 -- 形参设置初始值、拓展运算符、迭代器、生成函数
干货丨产品的可行性分析要从哪几个方面入手?
ES6 learning -- let
LM小型可编程控制器软件(基于CoDeSys)笔记十七:pto脉冲功能块
Fegin client entry test
MySQL数据库常用函数和查询
Oracle - getting started
Live800 online customer service system: do business across time and space, starting from each interaction
牛客小白月賽52--E 分組求對數和(二分)
Comp2913 database
UE4_UE5结合offline voice recognition插件做语音识别功能