Get answers quicker by searching

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

The script I use to import contacts via API
  • Vote Up0Vote Down jakobjakob
    Posts: 2Sendy user

    I need to trigger the confirmation autoresponder. There is a post of a similar name (, but due to redirects I'm throwing an error. Using some googling to find poorly undocumented curl parameters I changed the script to the following

    <?php //-------------------- EDIT HERE -----------------------// $sendy_url = 'YOUR-URL-TO-SENDY/'; $api_key = 'YOUR-SENDY-API-KEY'; $list_id = 'YOUR-SENDY-LIST-ID'; $csv_file = 'YOUR-CSV-FILE.csv'; //------------------------------------------------------// //------- DON'T CHANGE ANYTHING FROM HERE ONWARDS ------// ini_set('auto_detect_line_endings',TRUE); $file_handle = fopen($csv_file, "r"); $ch = curl_init(); while (!feof($file_handle) ) { set_time_limit(0); $line_of_text = fgetcsv($file_handle, 1024); $fields = array( 'name' => urlencode($line_of_text[0]), 'email' => urlencode($line_of_text[1]), 'api_key' => urlencode($api_key), 'list' => urlencode($list_id) ); foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string, '&'); curl_setopt($ch, CURLOPT_URL, $sendy_url.'/subscribe'); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_POSTREDIR, 3); if ($line_of_text[0] != ''){ curl_exec($ch); sleep(5); } echo $line_of_text[1]; echo '
    '; } fclose($file_handle); curl_close($ch); //------------------------------------------------------// ?>

    now, to get the script to work

    1. create a .csv-file with lines of NAME MORENAME,MAIL@ADDRESS.COM
    2. create an index.php-file with the code above
    3. edit the variables to match and save
    4. create a new folder on your server for a given domain (translating into a URL to visit)
    5. upload the .csv and the index.php to your server in the new folder
    6. visit the URL of the domain where you uploaded your files
    7. wait: the script will take some time to allow autoresponders to process the requests
    • you may want to password protect the folder so no one can trigger the script by accident when visiting the URL


This discussion has been closed.
All Discussions