使用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

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

I'm not sure but that would works :

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&api_data[list_id][]=2&api_data[list_id][]=3

You can only take an eye on json_encode() and json_decode() to make the transfer of data easier.

Finally, responding to a comment of your first post, do not use serialize/unserialize that is not intended to be used on users-supplied data. It could lead to PHP Object Injection.

Good luck,

Daniel