Automatic import

Dear,

Using prestashop and / phplist at the moment everytime i send a new message I need to import manually my new suscriber from prestashop.
Bau I’m running 7 website, with 7 prestashop and 7 phplist, It’s quite boring to need to do it everytime manually.

So i’m questionning my self about automatic import.
If I don’t have problem to export form prestashop I have no idea how to do it in phplist , expect if i developp my on mysql request.

Is there a any to simple import listr of email by a cron?

phplist doesn’t support importing subscribers from the command line (similar to process queue and process bounces) but you can use a program such as curl or wget to GET or POST phplist pages, as if it was being done by browser. That command can then be run by a cron job.

This topic in the old forums explains how it can be done, and still seems to work with the latest phplist.

For example, to import a file of email addresses (email.csv) into a list (list id 2) using the import subscribers page copy/paste option, this command can be used

curl -v -F login=admin -F password='xxxx' -F "importcontent=<email.csv" -F "importlists[0]=2" -F "checkvalidity=1" -F "doimport=Import emails" 'http://www.xxx.com/lists/admin/?page=importsimple&list=2' -o curlout.html

If you want to import user attributes in addition to the email address then you will need to figure out the actual POST command to use.

Another way is to use an API to access the phplist database, but that will require developing some code in php. See the plugin on GitHub.

3 Likes

yes, and new api soon would make this even easier. I use prestashop too. I agree, it can be tedious to sync.

Thanks That’s great.
Unfortunatly no way to import the file.

If I enter direcly no problem
curl -v -F login=admin -F password=‘XXX’ -F "importcontent=test@test.fr" -F “listname[0]=‘cus’” -F “importlists[0]=6” -F “checkvalidity=1” ‘http://www.XXX.com/lists/admin/?page=importsimple&list=6’ -o curlout.html

but as soon I tried with a file nothing happen
I tried
curl -v -F login=admin -F password=‘XXX’ -F “importcontent=@/home/XXX/e.csv” -F “listname[0]=‘cus’” -F “importlists[0]=6” -F “checkvalidity=1” ‘http://www.XXX.com/lists/admin/?page=importsimple&list=6’ -o curlout.html

Curl find the file, and the file content only on email adress?
So do you have any idea?

Do you have any Idea?

The character before the file name should be ‘<’ not ‘@’.

Thank
indeed do a php script to export from prestashop import to phplist

<?php
error_reporting(E_ALL); 
include(dirname(__FILE__).'/../../config/config.inc.php');
require_once(dirname(__FILE__).'/../../init.php');

$sql = 'SELECT `email`
				FROM `'._DB_PREFIX_.'customer`
				WHERE date_add > (NOW() - INTERVAL 7 DAY) AND newsletter = 1
				ORDER BY `id_customer` ASC';


if ($list = Db::getInstance()->ExecuteS($sql))
{
	foreach ($list as $fields) {
		$listing_email .=$fields["email"]."\n";

	}
$postfields = array();
$a = array();
$a["domaine1"]["domain"] = "domaine1";
$a["domaine1"]["login"] = "longinimpoirt";
$a["domaine1"]["password"] = "XXXXXXXXXXXXXXXXXXx";
$a["domaine1"]["page"] = "importsimple";
$a["domaine1"]["list"] = "6";
$a["domaine1"]["listname[0]"] = "cus";

$a["domaine2"]["domain"] = "domaine2";
$a["domaine2"]["login"] = "longinimpoirt";
$a["domaine2"]["password"] = "XXXXXXXXXXXXXXXXXXx";
$a["domaine2"]["page"] = "importsimple";
$a["domaine2"]["list"] = "5";
$a["domaine2"]["listname[0]"] = "cus";


	foreach ($a as $v1) {

		$url = "http://www.".$v1["domain"].".com/lists/admin/";
		$postfields["login"] = $v1["login"]; 
		$postfields["password"] = $v1["password"];
		$postfields["page"]=$v1["page"]; 
		$postfields["list"]=$v1["list"];
		$postfields["listname[0]"] = $v1["listname[0]"];
		$postfields["importlists[0]"] = $v1["list"];
		$postfields["checkvalidity"] = "1";
		$postfields["importcontent"] = $listing_email;
		$postfields["doimport"] = "submit"; 

		$ch = curl_init($url);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
		curl_setopt($ch, CURLOPT_HEADER, 0);
		curl_exec($ch);
		curl_close($ch);
	}
}
1 Like