Using curl inside a php application.

Once you've installed phpList... ask questions here!
Forum rules
Please help the volunteers to help you by supplying the version of phpList you are using, browser & version and if possible, a link to your phpList installation.

Using curl inside a php application.

Postby Praetorian » 5:21pm, Thu 14 Aug, 2014

I have been trying for the last few days to get a curl config that can signup people to the basic subscribe page in place of a basic html signup page. Below is part of my routine that generates no errors but also does not sign up the email to the list specified. I have tried the same email address from the html signup page and it works, but from this php version it does not. I am hoping someone here can point out my problem so I can get this working for a non profit.

Code: Select all
$post_data['email']=$_POST['email'];
$post_data['emailconfirm']=$_POST['emailconfirm'];
$post_data['htmlemail']=$_POST['htmlemail'];
$post_data['attribute1']=$_POST['attribute1'];
$post_data['attribute2']=$_POST['attribute2'];
$post_data['attribute3']=$_POST['attribute3'];
$post_data['attribute4']=$_POST['attribute4'];
$post_data['attribute5']=$_POST['attribute5'];
$post_data['list[5]']='signup';

foreach ( $post_data as $key => $value)
{
$post_items[] = $key."=".$value;
}
$post_string = implode ('&', $post_items);
echo $post_string."<br>";
$curl_connection = curl_init('http://news.domain.org/lists/?p=subscribe&id=1');
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 15);
curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");
curl_setopt($curl_connection, CURLOPT_REFERER, "http://news.domain.org/");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
curl_setopt($curl_connection, CURLOPT_VERBOSE, true);
$result = curl_exec($curl_connection);
echo $result."<br>";
echo curl_errno($curl_connection)."<br>";
echo curl_error($curl_connection)."<br>";
print_r(curl_getinfo($curl_connection));
curl_close($curl_connection);



Thanks.
Praetorian
phpList newbie
 
Posts: 2
Joined: 6:28pm, Thu 23 Jan, 2014

Return to Questions and Problems after Installing

Who is online

Users browsing this forum: No registered users and 3 guests

cron