The goal of this example is to show you what API calls to make so you can programmatically add a subscriber’s email (and other information) to a list at FeedBlitz. Let’s assume you’re developing a plugin for WordPress; any WP plugin developer should be able to integrate with FeedBlitz! The example below isn’t limited to plugins, of course; it can work with any web site, product or service you can extend programmatically. You use simple Web requests, so it’s pretty easy for a web developer to do.
The user of your plugin will need:
- A FeedBlitz premium account
- At least one active mailing list
- An active FeedBlitz API key from https://app.feedblitz.com/f?pl_api
Once you’ve validated the pre-reqs, you:
- Get a list of the publisher’s active lists from the REST API.
- Optionally get a list of custom fields and tags the publisher already has in FeedBlitz.
- In your configuration UI, the publisher:
- Picks a list that your plugin will subscribe visitors to.
- Optionally selects the custom fields to use, or specifies new ones using your UI.
When a visitor uses your plugin to join a list, you then:
- Present your UI, performing any necessary validation;
- Call the FeedBlitz Simple API to create the subscription
- Assuming all is well, FeedBlitz starts the dual opt-in process to add the subscriber.
The next section takes you through the process, step-by-step.
All URLs below are simple HTTP GETs (see, I said it was easy!)
Get a List of Active Mailing Lists
Use a quick call to the REST API as follows
The returned XML will contain one or more <syndication> elements, one for each active list. Grab the <id> and <name> elements within each. You will need to persist the <id> that the user selects. Add “text/xml” to your Accept-Type header to make the REST API work.
Get Active Custom Fields
If the publisher has custom fields defined in their account, it would be nice to offer those on your UI, right? Right! Here’s the REST API call:
The returned XML may contain or more <field> elements. Grab the <name> and the <id> and the <uihidden> elements. FeedBlitz allows publishers to create hidden custom fields; publishers can use hidden fields to track campaigns, referring pages, etc. Hidden fields should not be displayed to end users (i.e. not shown to site visitors or potential subscribers); it’s obviously ok to show them to the publisher during set up. If there are no custom fields defined, you can also offer your own (e.g. “Name”); FeedBlitz will add them when you send the data to FeedBlitz at subscription time. Again, this a REST API call, so be sure to add “text/xml” to your Accept-Type header before accessing the resource.
Save the relevant information and use it to build the user interface you want to present to site visitors.
Subscribe a visitor
Configuration all done, potential subscribers will now be using your user interface on the publisher’s web site. Based on the saved configuration and user-supplied data, and making sure as best you can that the visiting user agent is not a bot (recommended to prevent spambots: use <script> to generate your UI on the fly, and make sure there’s a valid referrer header); call the simple subscription API as mentioned last week with the correct parameters:
Optionally add tags and name / value pairs, again as mentioned over here.
It’s that easy. Two calls to assist in configuration, and one per new subscriber. FeedBlitz handles the entire dual opt-in process from there on, as well as all subscriber management such as bounce handling, unsubscribes etc.