Use WPNewsman API

All requests must be addressed to the script api.php

The script has two required parameters: method and key.

By default all methods respond with appropriate HTTP codes on errors. Sometimes an environment doesn’t allow to properly handle error responses, so you can add a “bepositive=1” parameter to your request and the plugin will always respond with the “200 Ok” HTTP code. In this case only the “state: false” property of the response JSON object will indicate an error.

Available methods:

  • addEmail adds the subscriber and sets the “Confirmed” status for him. The additional required parameter is email. Other parameters will be added to the JSON object in the database.
  • getLists returns the subscribers’ lists
  • downloadList returns the CSV file with subscribers. The additional required parameter is listId. The additional parameter links can contain the list of links that must be generated for each subscriber. Possible types of links are confirmation-link, resend-confirmation-link and unsubscribe-link. Other two parameters of this method are offset and limit. offset allows skip xx subscribers and return the subscribers starting from the xx number. limit allows limit the number of subscribers to return.

See the requests and responses below.

Request:

api.php?method=addEmail&key=xxxxxxxxxx&listId=2&email=john@doe.com&first-name=John&last-name=Doe

Response:

{
 state: true,
 msg: "Subscriber added",
 id: 123
}

Request:

api.php?method=getLists&key=xxxxxxxxxx

Response:

{
 state: true,
 msg: [
  {
   id: "1",
   uid: "7q2gTcW0dlBSwRaRPmr3iIDxXIM",
   name: "default" 
  },
  {
   id: "2",
   uid: "BSzdevzH4Yc_ti9nad3gJ7dkQSo",
   name: "wp-users" 
  }
 ]
}

Request:

api.php?method=downloadList&listId=1&links=unsubscribe-link&key=xxxxxxxxxx&

Response:

CSV file