I'm using the API to add subscribers from our website, taking data from an HTML form, then using PHP to call the API subscribe method.
It all works, including custom fields etc. except for the inclusion of a slash ('\') in names with an apostrophe eg. O'Brien.
I've tried using PHP stripslashes($lastname) when loading up the API subscriber record array, and it seems to be working OK on the server side (string variable contains O'Brien, not O\'Brien into lastname), but when I check my subscriber list, the names are going in there as:
How do I ensure the names are entered into the subscriber list without the escape slash (or have I done something else wrong, or is this the default for CM?)
It looks like the request we are getting contains something like "O\'Brien", so we are keeping that slash in the name. Is your code perhaps adding slashes for some reason before the subscriber details is sent our way?
Thanks for the prompt reply.
I was using stripslashes on my custom fields lastname (and firstname FWIW), but hadn't done the same to the main Name variable of the CM API subscriber array. Sorry, my bad, all working now, thanks again.
A note for others: if you're doing things like stripping slashes to lastname and firstname custom fields, don't forget to handle the main Name field as well. It looks like what you put in lastname and firstname will not override Name.
ps. I've found the CM API is great to work with, reliable, sensibly designed and does exactly what it says!