Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Developed by Riccardo Mel
- include ("mailchimp-config.php");
- //Vars - Una volta settato consiglio di cambiare in POST
- $action = $_GET["action"];
- $email = $_GET["email"];
- $fname = $_GET["fname"];
- $debug = isset($_GET["debug"])?$_GET["debug"]:0;
- $listid = $_GET["listid"];
- $auth = base64_encode( 'user:'.$apiKey );
- if ($debug) {
- echo "Debug On <br><br>";
- echo $action;
- echo "<br><br>";
- echo $email;
- echo "<br><br>";
- echo $fname;
- echo "<br><br>";
- echo $listid;
- echo "<br><br>";
- }
- if (!isset($email) && $action == "subscribe") {
- echo "Nessuna email specificata con questo metodo <br><br>";
- return;
- }
- //CURL
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $server."/lists/".$listid."/members");
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: Basic '.$auth));
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_TIMEOUT, 10);
- switch($action) {
- case "subscribe":
- $data = array(
- 'apikey' => $apiKey,
- 'email_address' => $email,
- 'status' => 'subscribed',
- 'merge_fields' => array(
- 'FNAME' => $fname
- )
- );
- $json_data = json_encode($data);
- //NECESSARIO SOLO PER Aggiunta = POST + PARAMETRI
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
- //NECESSARIO SOLO PER Aggiunta = POST + PARAMETRI
- //curl_exec
- $result = curl_exec($ch);
- if ($debug) { echo "Aggiunto: ".$fname." <br><br>"; print_r($result); }
- break;
- case "lists":
- $result = curl_exec($ch);
- print_r($result);
- if ($debug) { echo "Lista utenti mailchimp <br><br>"; }
- break;
- default:
- echo "Azione non consentita <br><br>";
- break;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement