get - Check whether email is subscribed to list in MailChimp API 3.0 using PHP -


i've read following on mailchimp website:

mailchimp api v3.0 live! prior versions no longer supported after 2016, api users should begin transitioning v3.0.

as result, move v3.0 of api. please have function, in php, returns boolean, check whether email address subscribed specific mailchimp list. not want subscribe user, merely check whether subscribed or not.

looking @ mailchimp documentation , assuming have given list in mind, looks call endpoint get: /lists/{list_id}/members/{subscriber_hash}

to in php, found nice script sitting on github. last function trick you:

function mc_checklist($email, $debug, $apikey, $listid, $server) {     $userid = md5($email);     $auth = base64_encode( 'user:'. $apikey );     $data = array(         'apikey'        => $apikey,         'email_address' => $email         );     $json_data = json_encode($data);     $ch = curl_init();     curl_setopt($ch, curlopt_url, 'https://'.$server.'.api.mailchimp.com/3.0/lists/'.$listid.'/members/' . $userid);     curl_setopt($ch, curlopt_httpheader, array('content-type: application/json',         'authorization: basic '. $auth));     curl_setopt($ch, curlopt_useragent, 'php-mcapi/2.0');     curl_setopt($ch, curlopt_returntransfer, true);     curl_setopt($ch, curlopt_timeout, 10);     curl_setopt($ch, curlopt_post, true);     curl_setopt($ch, curlopt_customrequest, "get");     curl_setopt($ch, curlopt_ssl_verifypeer, false);     curl_setopt($ch, curlopt_postfields, $json_data);     $result = curl_exec($ch);     if ($debug) {         var_dump($result);     }     $json = json_decode($result);     echo $json->{'status'}; } 

if function doesn't work, wrapper find v3 library works in conjunction laravel - mailchimp v3 api php wrapper.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -