Hi ! I need simple add/delete member to list using rest ..... but all documentation is for python and not helpfull for me, .... and I need these in CLI using curl command ....
To add member using CLI i tried this command:
curl -d "{'list_id' : 'list.domain.com', 'subscriber' : 'user@email.com'}" -H 'Content-Type: application/json' --user restadmin:restpass http://localhost:8001/3.0/members
and I got this response: Missing parameters: list_id, subscriber
What is wrong in above command here ? ..... I need to add user: user@email.com to list: list@domain.com Also, if someone is willing to give example: delete user: user@email.com from list: list@domain.com
I actually create PHP application .... but CLI example is easy to reproduce in PHP
function AddUserToList($user,$lista) { $url = 'http://llocalhost:8001/3.0'; $request_url = $url . '/members'; $data = array("list_id" => $lista,"subscriber" => $user ); $postdata = json_encode($data); $ch = curl_init($request_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERPWD, "restadmin:restpass"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); $result = curl_exec($ch); curl_close($ch); print_r ($result); }
AddUserToList('user@email.com','list.domain.com');