سؤال

I'm trying to submit a form using PHP and the mailchimp 2.0 api.

I'm getting an error that says:

FNAME must be provided 

My form has a field for the first name:

<input type="text" name="fname">

So it must have something to do with the way I am handling it the php side.

Here is the bit of php that handles FNAME:

$result = $MailChimp->call('lists/subscribe', array(
'id'                => 'myid',
'email'             => array( 'email' => $_POST['email']),
'FNAME'             => $_POST['fname'],
'LNAME'             => $_POST['lname'],
'double_optin'      => false,
'update_existing'   => true,
'replace_interests' => false

));

I'm not sure if I'm forming the array correctly or not.

By the way, I'm using this wrapper, but I think my error has to do with how I create $result and not the wrapper.

https://github.com/drewm/mailchimp-api

Any help would be appreciated.

Thanks!

هل كانت مفيدة؟

المحلول

Peep the example at the bottom of the page you linked to. I've pasted it here:

$result = $MailChimp->call('lists/subscribe', array(
            'id'                => 'b1234346',
            'email'             => array('email'=>'davy@example.com'),
            'merge_vars'        => array('FNAME'=>'Davy', 'LNAME'=>'Jones'),
            'double_optin'      => false,
            'update_existing'   => true,
            'replace_interests' => false,
            'send_welcome'      => false,
        ));
print_r($result);

Your merge vars (ex. FNAME and LNAME) need to be in its own array. So, add a 'merge_vars' in your array and create an array that contains your field's merge variables.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top