Mailchimp API v3 if statement
<p>I have a simplified Mailchimp API call to our specific list to see if a user is subscribed or not.  Everything works fine however we want to take that information and perform other functions based on the result.  For example if they are not subscribed we would like to add them to that list.  If they are we would like to display a message.  The trouble I'm running into is my if statement is not working.  Please see below.  By all accounts the page should say "have a good day".  But nothing is returning.</p>

<pre><code>$api = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx-us6';
$server = 'us6';
$listid = 'xxxxxx';
$debug = 1;
$email = 'EMAIL THAT IS ON THE LIST';

function mc_checklist($email, $debug, $apikey, $listid, $server) {
    $userid = md5($email);
    $auth = base64_encode( 'user:'. $apikey );
    $data = array(
        'apikey'        =&gt; $apikey,
        'email_address' =&gt; $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-&gt;{'status'};

    die();
}

mc_checklist($email, $debug, $api, $listid, $server );

if ($json-&gt;{'status'} == "subscribed") {
echo "Have a good day!";
}
</code></pre>

<p>RESULTS</p>

<pre><code>    string(2669) "{"id":"b975283169c19f4072fc79202b4c5ede","email_address":"sgembar1@gmail.com","unique_email_id":"7a5737201e","email_type":"html","status":"subscribed","merge_fields":{"FNAME":"Stephen","LNAME":"Gembar","MMERGE3":"33510","MMERGE4":"08/08"},"stats":{"avg_open_rate":0,"avg_click_rate":0},"ip_signup":"","timestamp_signup":"","ip_opt":"107.170.5.35","timestamp_opt":"2016-12-13T21:42:06+00:00","member_rating":2,"last_changed":"2016-12-13T21:42:06+00:00","language":"","vip":false,"email_client":"","location":{"latitude":0,"longitude":0,"gmtoff":0,"dstoff":0,"country_code":"","timezone":""},"list_id":"df8eaa3df5","_links":[{"rel":"self","href":"https://us6.api.mailchimp.com/3.0/lists/df8eaa3df5/members/b975283169c19f4072fc79202b4c5ede","method":"GET","targetSchema":"https://us6.api.mailchimp.com/schema/3.0/Definitions/Lists/Members/Response.json"},{"rel":"parent","href":"https://us6.api.mailchimp.com/3.0/lists/df8eaa3df5/members","method":"GET","targetSchema":"https://us6.api.mailchimp.com/schema/3.0/Definitions/Lists/Members/CollectionResponse.json","schema":"https://us6.api.mailchimp.com/schema/3.0/CollectionLinks/Lists/Members.json"},{"rel":"update","href":"https://us6.api.mailchimp.com/3.0/lists/df8eaa3df5/members/b975283169c19f4072fc79202b4c5ede","method":"PATCH","targetSchema":"https://us6.api.mailchimp.com/schema/3.0/Definitions/Lists/Members/Response.json","schema":"https://us6.api.mailchimp.com/schema/3.0/Definitions/Lists/Members/PATCH.json"},{"rel":"upsert","href":"https://us6.api.mailchimp.com/3.0/lists/df8eaa3df5/members/b975283169c19f4072fc79202b4c5ede","method":"PUT","targetSchema":"https://us6.api.mailchimp.com/schema/3.0/Definitions/Lists/Members/Response.json","schema":"https://us6.api.mailchimp.com/schema/3.0/Definitions/Lists/Members/PUT.json"},{"rel":"delete","href":"https://us6.api.mailchimp.com/3.0/lists/df8eaa3df5/members/b975283169c19f4072fc79202b4c5ede","method":"DELETE"},{"rel":"activity","href":"https://us6.api.mailchimp.com/3.0/lists/df8eaa3df5/members/b975283169c19f4072fc79202b4c5ede/activity","method":"GET","targetSchema":"https://us6.api.mailchimp.com/schema/3.0/Definitions/Lists/Members/Activity/Response.json"},{"rel":"goals","href":"https://us6.api.mailchimp.com/3.0/lists/df8eaa3df5/members/b975283169c19f4072fc79202b4c5ede/goals","method":"GET","targetSchema":"https://us6.api.mailchimp.com/schema/3.0/Definitions/Lists/Members/Goals/Response.json"},{"rel":"notes","href":"https://us6.api.mailchimp.com/3.0/lists/df8eaa3df5/members/b975283169c19f4072fc79202b4c5ede/notes","method":"GET","targetSchema":"https://us6.api.mailchimp.com/schema/3.0/Definitions/Lists/Members/Notes/CollectionResponse.json"}]}" subscribed
</code></pre>