3
I tested a script to integrate forms with Mailchimp:
<?php
// MailChimp API URL
$memberID = md5(strtolower($email_popup));
$dataCenter = substr($apiKey,strpos($apiKey,'-')+1);
$url = 'https://' . $dataCenter . '.api.mailchimp.com/3.0/lists/' . $listID . '/members/' . $memberID;
// member information
$json = json_encode([
'email_address' => $email_popup,
'status' => 'subscribed',
'merge_fields' => [
'FNAME' => $nome_empresa_popup,
'CIDADE' => $cidade_estado_popup,
'MMERGE4' => $vendedor_popup
]
]);
// send a HTTP POST request with curl
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERPWD, 'user:' . $apiKey);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
?>
On the server of my site, it worked correctly.
But on the client server, the following error is occurring:
Parse error: syntax error, Unexpected '[', expecting ')' in /home/{domain}/public_html/{site}/pages/modal.php on line 511
Which is on that line:
$json = json_encode([
I searched the PHP documentation for something, but found nothing related to the syntax error.
Try changing the way you declare the array, instead of putting it like this [] put array()
– Wictor Chaves
which version of php from the client server?
– Costamilam
The one on my site is 5.6. The one on the customer is 5.2.
– Rogério Pancini