首页 > 编程语言 > 详细

利用Flurl.Http库,在PHP实现的接口中参数数组的传递

时间:2021-07-21 09:41:21      阅读:14      评论:0      收藏:0      [点我收藏+]
在实际开发过程中我们发现,PHP实现的后台接口,需要数组参数时,C#中直接传递数组或集合,PHP皆不正确接收。在Post接口中传递数组需要采用以下方式传递。

 

 1 /// <summary>
 2 ///php写的后台接口传递数组参数时需要单独处理,不能直接用List<object>
 3 /// UrlEncoded 数组参数的传递
 4 /// </summary>
 5 /// <returns></returns>
 6  async Task SendArraryDemo()
 7  {
 8     string url = "";
 9     // post
10    await url.PostUrlEncodedAsync(new Dictionary<string, object>
11      {
12             ["array[]"] = new[] { 1, 2, 3, 4 },//传递整数数组
13             ["other"] = "other paramter"
14           });
15  
16      //send
17      await url.SendUrlEncodedAsync(HttpMethod.Post,
18 // HttpMethod.Delete || HttpMethod.Put ||
19          new Dictionary<string, object>
20          {
21             ["array[]"] = new[] { 1, 2, 3, 4 },//传递整数数组
22             ["other"] = "other paramter"
23          });
24  
25  }
26  

 

利用Flurl.Http库,在PHP实现的接口中参数数组的传递

原文:https://www.cnblogs.com/pangzishuoma/p/15037933.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!