Subscribe via URL

Dmitriy K

Member
Hi! Any body know the way to add subscriber to list by simple URL request with name and email variables?

I need add my customers to list in background mode after they are purchase something. But in my shop i cant use API, only URL requests
 
I make and test a simple solution for all, working good.

Create file subscribemagic.php in root directory of MailWizz script with next code:

<?php
$hostname = "your_mailwizz_domain.com"; //add you domain here
$email = $_GET['email'];
$name = $_GET['name'];
$list_id = $_GET['list_id'];
$data="EMAIL=$email&FNAME=$name";
$fp = fsockopen("$hostname", 80, $errno, $errstr, 10);
$out = "POST /index.php/lists/$list_id/subscribe HTTP/1.1\n";
$out .= "Host: $hostname\n";
$out .= "Referer: $hostname/\n";
$out .= "User-Agent: Opera\n";
$out .= "Content-Type: application/x-www-form-urlencoded\n";
$out .= "Content-Length: ".strlen($data)."\n\n";
$out .= $data."\n\n";
fputs($fp, $out);
fclose($fp);

URL for subscribe:
Code:
http://your_mailwizz_domain.com/subscribemagic.php?name=NAME_VARIABLE&email=EMAIL_VARIABLE&list_id=YOUR_LIST_ID

What you set in NAME_VARIABLE and EMAIL_VARIABLE depends from your shop-script(in my case this is %name% and %email%

P.S. Dont forget set file owner to www-root and rights to 644
 
Last edited:
Back
Top