API Location in 3.4.1

The blog post about 3.4.1 (phpList 3.4.1 has been released ) indicates that the API is now in this location: https://www.example.com/lists/api/v2 .

I did a brand new install yesterday, and do not find that folder in the unzipped/installed files.

Note that other documentation areas have not caught up to the new API folder location.

But where, exactly, is the API in 3.4.1?

Thanks…Rick…

The API url is handled via Webserver rewriting rules so the URL doesn’t reflect directory structure. The scripts which serve API requests are in the base folder. You should check .htaccess files for the configuration of the rewriting for the details.

Thanks for the info. My CURL post is this (sanitized)

https://www.example.com/maillist/admin/api/v2/?login=username&password=thepassword

The response returns
{"code":404,"message":"Not Found"}

I have not made any changes to the htaccess file. The program is stored in the ‘maillist’ folder of my site.

Next step?

THanks…Rick…

This doesn’t match the URL you showed in your first post.

As stated in my previous reply, the program is installed in the ‘maillist’ folder of my site. So the URL for the ‘root’ of the program is https://www.example.com/maillist .

To that ‘root’, i added the /admin/api/v2 to the CURLOPT_URL value. Then the query parameters are added to the CURLOPT_POSTFIELDS value, which contains the user and password values (created by an http_query of the query array previously built.

So, the result is a CURL POST equivalent to https://www.example.com/maillist/admin/api/v2/?login=username&password=thepassword . Which returns the 402 not found as the JSON response.

If I do that URL manually (in my browser, with the actual domain/user/password values), I still get the 402.

If I go to https://www.example.com/maillist in the browser, I get the phpList 'visitor page (‘subscribe’, ‘update preferences’, etc).

The example URL doesn’t include ‘/admin’.

OK, I misread the release docs referenced in my original question.

I have successfully CURL’d a login. Now the issue is when I try to add a subscriber. Below is my code for the two separate CURL requests.

$url                      = "https://www.example.com/maillist/api/v2/sessions";
$login                    = "admin"; // phplist admin Login
$pass                     = "password"; // phplist admin password
$login_data               = array();
$login_data["login_name"] = $login;
$login_data["password"]   = $pass;
$post_params = http_build_query($login_data);
$data_string = json_encode($login_data);
$ch          = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
	'Content-Type: application/json',
	'Content-Length: ' . strlen($data_string)
	)
);
$result = curl_exec($ch);
/* response (200)
 	 {"expiry":"2019-04-27T01:37:24+00:00","key":"83bf2b137fb2a6272e641906c0b21c5a","id":165} 

*/

$decoded = json_decode($result, true);
$key = $decoded["key"];
$id  = $decoded["id"];

$url         = "https://www.example.com/maillist/api/v2/subscribers";
$confirmed   = true;
$blacklisted = false;
$html_email  = true;
$disabled    = false;
$params      = array(
	'email' => 'mickey@mouse.com',
	'confirmed' => $confirmed,
	'blacklisted' => $blacklisted,
	'html_email' => $html_email,
	'disabled' => $disabled,
	'key' => $key,
	'id' => $id,
);
$data_string = json_encode($params);
//$ch                       = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
	'Content-Type: application/json',
	'Content-Length: ' . strlen($data_string),
	'Authorization: Basic ' . $key,
	)
);
$result = curl_exec($ch);
/* response = 
	{"code":403,"message":"Forbidden"} 
*/

As far as I can tell, I’ve got the correct parameters for the 2nd CURL that is supposed to add the subscriber. But, obviously, I am missing something, as I get a ‘403:forbidden’ response to the 2nd CURL.

Thanks…Rick…