I need someone to write a script in PHP that adds a user to a list. My membership software can call an external URL whenever a new membership is created or a membership expires. I can specify that the URL it calls is something like:
http://www.mysite.com/adduser.php?name=[name]&email=[email]. The membership software inserts the appropriate value into [name] and [email].
So the script just needs to grab the name and email from the URL and then add them to a specified list in CM.
I need a second version that removes a user from a list if their subscription lapses.
There are three membership levels, each with their own mailing list. So I will need three versions of the subscribe script and three unsubscribe scripts.
Can you help?
I think this is what you need to do:
1. Grab your API key from the "Account Settings" page of your Campaign Monitor account.
2. Download createsend-php. It's a PHP client library for our API.
3. Write your adduser.php script such that it accepts three query string parameters: listid, name, and email. With these three parameters, make a call to the CS_REST_Subscribers.add method in the same way it is called in the add sample provided.
4. Write your unsubscribeuser.php script such that it accepts two query string parameters: listid, and email. With these two parameters, make a call to the CS_REST_Subscribers.unsubscribe method in the same way it is called in the unsubscribe sample provided.
The reason I have said you'll probably want to allow your script to accept a listid parameter is that you'll probably have three separate lists for the three different categories of membership. So you'll need to know "API Subscriber List ID" for each list. You can get this for a list by going to the list detail page and clicking the "change name/type" link below the list name.
So while I have not written the code for you (because I cannot do so right at the moment), that sounds like what you need to do based on your description above. Hope that helps.
Actually that did help. My programming knowledge is almost zero but I worked it out.
From Australia to Zimbabwe, and everywhere in between, companies count on Campaign Monitor for email campaigns that boost the bottom line.Get started for free