Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2007
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem using mailchimp api

    Hey all.

    First off as always thanks in advance. I'm no expert when it comes to php so I appreciate the help.

    What I'm trying to do:
    Send data from my form to Mailchimp api. Specifically email, name and birthday.

    What it currently does:
    Sends email and name

    What it wont do:
    Send the birthday

    I know I'm doing something stupid here and that it is a simple fix but I just can work it out!

    The simple guide to the function I'm using from the api is here > http://apidocs.mailchimp.com/api/1.3...cribe.func.php

    As you can see it prefers to have the birthday in the MM/DD format.

    PHP Code:
    $month $_POST['Month'];
    $year $_POST['Year'];

    //Create Birthday in mm/dd format for mailchimp
    $birthday $month."/".$day
    I then use the function to send the data (which as I mentioned above works for everything APART from the birthday!

    PHP Code:
    function SubscribeToList($listId$name$email)
    {
     global 
    $apiKey;
     
    $api = new MCAPI($apiKey);
     
    $parsedName ParseName($name);
     
    $mergeVars = array('FNAME' => $parsedName['first'], 'LNAME' => $parsedName['last'], 'birthday'=>"$birthday");
     
     
    $success $api->listSubscribe($listId$email$mergeVars'html'false);
     return 
    $success


    I get the feeling this is me using the wrong syntax, but I've been trying to get this to work for about two days!

    What am I doing wrong here?

    Many thanks,

  • #2
    New Coder
    Join Date
    Oct 2007
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Specifically I think it's a problem with this line:

    PHP Code:
    $mergeVars = array('FNAME' => $parsedName['first'], 'LNAME' => $parsedName['last'], 'birthday' => $birthday); 

  • #3
    New Coder
    Join Date
    Oct 2007
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have narrowed it down now.

    If I use this line I get the birthday appearing in Mailchimp.
    PHP Code:
    $mergeVars = array('FNAME' => $parsedName['first'], 'LNAME' => $parsedName['last'], 'BDAY'=>"04/04"); 
    But then if I try to inject the string it doesn't work. I must be doing a stupid syntax thing here?
    PHP Code:
    $mergeVars = array('FNAME' => $parsedName['first'], 'LNAME' => $parsedName['last'], 'BDAY'=>"$birthday"); 
    Thanks,


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •