Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-31-2012, 10:16 AM   PM User | #1
eon201
New Coder

 
Join Date: Oct 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
eon201 is an unknown quantity at this point
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,
eon201 is offline   Reply With Quote
Old 03-31-2012, 11:17 AM   PM User | #2
eon201
New Coder

 
Join Date: Oct 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
eon201 is an unknown quantity at this point
Specifically I think it's a problem with this line:

PHP Code:
$mergeVars = array('FNAME' => $parsedName['first'], 'LNAME' => $parsedName['last'], 'birthday' => $birthday); 
eon201 is offline   Reply With Quote
Old 03-31-2012, 12:28 PM   PM User | #3
eon201
New Coder

 
Join Date: Oct 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
eon201 is an unknown quantity at this point
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,
eon201 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:09 PM.


Advertisement
Log in to turn off these ads.