subscribe via PHP:curl

Use this forum for questions regarding adoption and functionality of OpenEMM

Moderator: moderator

csl-computer
Posts: 6
Joined: Fri Mar 28, 2008 8:48 am

subscribe via PHP:curl

Post by csl-computer »

I have a huge problem in implementing the subscribtion form on our website.
Our website is fully SSL protected, so transfering the users data from the subscribtion form to an uncrypted server (our OpenEMM-server) results in a warning message from the internet-browser. To workaround this warning I want to transfer the data in a server-to-server communication using PHP and curl.
On the first look it works good ... the recipients entries are made in OpenEMM ... also the german Umlaut problem with ISO -> UTF-8 I got solved. But OpenEMM doesn't send a double opt-in email to the recipient.
When I use a html-file local or on the server with the subscription form in it and apply to the warning message (sending unencryted data) the email was send by the OpenEMM server but not when sending the data through curl ... I have no ideas anymore.
I hope someone else have some!

the PHP code for sending the data is the following:

Code: Select all

$url = 'http://mail3.csl-computer.com/form.do';
	$post_data = 'agnCI=1&agnFN=de_doi_confirm&agnSUBSCRIBE=1&agnMAILINGLIST=3&gender' . $_POST['gender'] . '&firstname=' . iconv("ISO-8859-15","UTF-8",$_POST['firstname']) . '&lastname=' . iconv("ISO-8859-15","UTF-8",$_POST['lastname']) . '&EMAIL=' . iconv("ISO-8859-15","UTF-8",$_POST['EMAIL']) . '&mailtype=' . $_POST['mailtype'];
	$fp = tmpfile();
	$curl = curl_init();
	curl_setopt($curl, CURLOPT_URL, $url);
	curl_setopt($curl, CURLOPT_POST, TRUE);
	curl_setopt($curl, CURLOPT_TIMEOUT, 20);
	curl_setopt($curl, CURLOPT_FILE, $fp);
	curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
	curl_setopt($curl, CURLOPT_VERBOSE, 1);
	curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
	curl_setopt($curl, CURLOPT_REFERER, "https://www.csl-computer.com/shop/shop_content.php?coID=21");
	curl_setopt($curl, CURLOPT_FAILONERROR, TRUE);
	curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
	curl_setopt($curl, CURLOPT_COOKIEFILE, 'cookiefile');
	curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookiefile');
	
	$status = curl_exec($curl);
	$response['http_code'] = curl_getinfo($curl, CURLINFO_HTTP_CODE);
	
	if ($status) {
	    $response['error'] = curl_error($curl);
	    $response['errno'] = curl_errno($curl);
	}
	
	curl_close($curl);
	
	rewind($fp);
	
	$response['data'] = '';
	while ($str = fgets($fp, 4096)) {
	    $response['data'] .= $str;
	}
	fclose($fp);
csl-computer
Posts: 6
Joined: Fri Mar 28, 2008 8:48 am

found the solution

Post by csl-computer »

The solution was corecting a failure in the postdata variable ... there was a "=" missing!!
sr-ska
Posts: 22
Joined: Tue Mar 19, 2013 6:56 pm

Re: subscribe via PHP:curl

Post by sr-ska »

It works well, but if the user already exists in another mailing list in the database, nothing happens.

How could this be improved?
Post Reply