Categories

Follow this Thread

PHP: Finding if an email is subscribed

Using the API, I am able to subscribe, resubscribe and unsubscribe successfully, but I can't figure out how check if an email address is active, or unsubscribed. The end goal, is basically if subscribed, echo a unsubscribe link, if not subscribed echo a subscribe link.

After digging around CMBase it appears that subscribersGetIsSubscribed() is what I need to target. I've successfully been able to tap into the function and get the proper true/false response when I echo $cm->debug_response. However, when I apply that into an if/else statement it doesn't work properly.

You should use the $result object rather than cm->debug. If you print_r($result); you will see an error code and a description if there is an error.In this case you missed to pass a ListID with the subscriber.. function.This should work:

Thank you very much. In the PHP examples it would always have a commented out print_r for the cm object at the end of the example, so I thought what I was looking for was in there. It never really made sense to me, but I am somewhat new to OOP, so I figured maybe there just wasn't something I was getting. Checking the $result variable makes much more sense to me, thanks.

Here's what I don't understand... what is "anyType" and why isn't it documented anywhere?? Or is it? I haven't found it in the API docs, in the PHP wrapper docs/comments or anywhere else... what is with this "anyType"?

I had the same problem, and the only way I solved it was by using print_r - like you mentioned - which showed an array with a single, mysterious "anyType" key in it... what does it mean? :) Could someone document it somewhere?

It seems that you where working on something that I am currently struggling to get working myself.

Its with the API Wrapper and the subscribersGetIsSubscribed tag. I can't seem to get the API to work, I wondered if there was any chance you could show me an example of your 'full code' (excluding any of your own personal API codes, obviously.), so I can possibly see where I am going wrong?

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.