Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #10005683
    JohnMMG
    Participant

    I am so close to live but can not get this to work? I have doen everything correctly … I believe. See code below with indication of where ID’s Keys and URL is changed. Help … please?

    <?php
    /*
    Name: Newsletter Subscribe
    Written by: Okler Themes – (http://www.okler.net)
    Version: 3.4.0
    Based On: https://gist.github.com/mfkp/1488819
    */

    session_cache_limiter(‘nocache’);
    header(‘Expires: ‘ . gmdate(‘r’, 0));
    header(‘Content-type: application/json’);

    $apiKey = ‘Key is here; – // How get your Mailchimp API KEY – http://kb.mailchimp.com/article/where-can-i-find-my-api-key
    $listId = ‘ID is here’; – // How to get your Mailchimp LIST ID – http://kb.mailchimp.com/article/how-can-i-find-my-list-id
    $submit_url = “http://us9.api.mailchimp.com/1.3/?method=listSubscribe&#8221;; – // Replace us2 with your actual datacenter

    $double_optin = false;
    $send_welcome = false;
    $email_type = ‘html’;
    $email = $_POST[’email’];
    $merge_vars = array();

    $data = array (
    ’email_address’ => $email,
    ‘apikey’ => $apiKey, = ‘Key is here’;
    ‘id’ => $listId, = ‘ID is here’;
    ‘double_optin’ => $double_optin,
    ‘send_welcome’ => $send_welcome,
    ‘merge_vars’ => $merge_vars,
    ’email_type’ => $email_type
    );

    $payload = json_encode($data);

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $submit_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, urlencode($payload));

    $result = curl_exec($ch);
    curl_close ($ch);

    $data = json_decode($result);

    if ($data->error) {
    $arrResult = array (‘response’=>’error’,’message’=>$data->error);
    } else {
    $arrResult = array (‘response’=>’success’);
    }

    echo json_encode($arrResult);


    #10005696
    Support
    Keymaster

    Hello, looks like there’s a problem in the line 25 and 26 of that file, please use the following script:

    (replace all the file php/newsletter-subscribe.php with that)

    <?php
    /*
    Name: 			Newsletter Subscribe
    Written by: 	Okler Themes - (http://www.okler.net)
    Version: 		3.5.0
    Based On: 		https://gist.github.com/mfkp/1488819
    */
    
    session_cache_limiter('nocache');
    header('Expires: ' . gmdate('r', 0));
    header('Content-type: application/json');
    
    $apiKey 	= '11111111111111111111111111111111-us4'; - // How get your Mailchimp API KEY - http://kb.mailchimp.com/article/where-can-i-find-my-api-key
    $listId 	= '1111111111'; - // How to get your Mailchimp LIST ID - http://kb.mailchimp.com/article/how-can-i-find-my-list-id
    $submit_url	= "http://us4.api.mailchimp.com/1.3/?method=listSubscribe"; - // Replace us2 with your actual datacenter
    
    $double_optin = false;
    $send_welcome = false;
    $email_type = 'html';
    $email = $_POST['email'];
    $merge_vars = array();
    
    $data = array(
        'email_address' => $email,
        'apikey' => $apiKey,
        'id' => $listId,
        'double_optin' => $double_optin,
        'send_welcome' => $send_welcome,
    	'merge_vars' => $merge_vars,
        'email_type' => $email_type
    );
    
    $payload = json_encode($data);
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $submit_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, urlencode($payload));
    
    $result = curl_exec($ch);
    curl_close ($ch);
    
    $data = json_decode($result);
    
    if ($data->error) {
        $arrResult = array ('response'=>'error','message'=>$data->error);
    } else {
        $arrResult = array ('response'=>'success');
    }
    
    echo json_encode($arrResult);

    Change just the line 13, 14 and 15.

    Please try that and let me know if you need further assistance.

    Kind Regards, Jonas


Viewing 2 posts - 1 through 2 (of 2 total)

This topic is marked as "RESOLVED" and can not rceive new replies.