doudie2693 2015-08-25 16:05
浏览 47

使用Array中的Array创建Post URL

I have an API:

$data = array( 
2     'api_method'        =>   'subscriber_add',  
3     'api_key'           =>   '3009', 
4     'api_data'          =>   array( 
5         'email'             => "email@domain.com", 
6         'list_id'           =>   array(1,2,3), 
7     ) 
8 );  

I am having problems on sending in list_id of '1' with the below sql. Email is working.

http://URL_ADDRESS.com/admin-ajax.php?action=newsletters_api&api_method=subscriber_add&api_key=67185672AFD27C3A62D6855E95288F87&api_data[email]=email@domain.com&api_data[list_id]=1

How do I deal with an array within an array

  • 写回答

2条回答 默认 最新

  • drtsd7864 2015-08-25 16:13
    关注

    If you are sending a POST you could send that data in the body of your petition. But I imagine you must to change your API method admin-ajax.php?action=newsletters_api

    An example of your POST body content would be:

    {
        'api_method' : 'subscriber_add',
        'api_key':'3009',
        'api_data':[
                { 'email':'email@domain.com'},
                { 'list_id': [1,2,3]}
            ]
    }
    

    In case you can't do that, you can send your array as a string separated by commas:

    http://URL_ADDRESS.com/admin-ajax.php?action=newsletters_api&api_method=subscriber_add&api_key=67185672AFD27C3A62D6855E95288F87&api_data[email]=email@domain.com&api_data[list_id]=1,2,3
    

    And parse that inside your code

    评论

报告相同问题?

悬赏问题

  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失