'New Campaign Title', 'description' => 'Description of the new campaign', // Optional ]; // Initialize cURL session $ch = curl_init($url); // Set cURL options for the POST request curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Execute the request and get the response $response = curl_exec($ch); // Check for errors in the cURL request if ($response === false) { echo 'cURL Error: ' . curl_error($ch); } else { // Print the response from the API echo 'Response: ' . $response; } // Close the cURL session curl_close($ch); exit; // ==================================== // EDIT A CAMPAIGN // ==================================== // API Key $apiKey = '[api_key]'; $campaignId = '[id]'; // URL for the PUT request $url = "https://leadswift.com/api/campaigns/{$campaignId}?api_key={$apiKey}"; // Data to be sent with the request $data = [ 'campaign_id' => $campaignId, 'title' => 'Updated Campaign Title', 'description' => 'Updated campaign description', // Optional ]; // Initialize cURL session $ch = curl_init($url); $data = http_build_query($data); // Set cURL options for the PUT request curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'Content-Length: ' . strlen($data) ]); // Execute the request and get the response $response = curl_exec($ch); // Check for errors in the cURL request if ($response === false) { echo 'cURL Error: ' . curl_error($ch); } else { // Print the response from the API echo 'Response: ' . $response; } // Close the cURL session curl_close($ch); exit; // ==================================== // DELETE A CAMPAIGN // ==================================== // API Key $apiKey = '[api_key]'; // Campaign ID to delete $campaignId = '[id]'; // URL for the DELETE request $url = "https://leadswift.com/api/campaigns/{$campaignId}?api_key={$apiKey}"; // Initialize cURL session $ch = curl_init($url); // Set cURL options for the DELETE request curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Execute the request and get the response $response = curl_exec($ch); // Check for errors in the cURL request if ($response === false) { echo 'cURL Error: ' . curl_error($ch); } else { // Print the response from the API echo 'Response: ' . $response; } // Close the cURL session curl_close($ch); exit; // ==================================== // GET SEARCHES OF A CAMPAIGN // ==================================== // API Key $apiKey = '[api_key]'; // Campaign ID to get searches for $campaignId = '[id]'; // URL for the GET request $url = "https://leadswift.com/api/searches/{$campaignId}?api_key={$apiKey}"; // Initialize cURL session $ch = curl_init($url); // Set cURL options for the GET request curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPGET, true); // Execute the request and get the response $response = curl_exec($ch); // Check for errors in the cURL request if ($response === false) { echo 'cURL Error: ' . curl_error($ch); } else { // Print the response from the API echo 'Response: ' . $response; } // Close the cURL session curl_close($ch); exit; // ==================================== // SUBMIT A SEARCH // ==================================== // API Key $apiKey = '[api_key]'; // URL for the POST request $url = "https://leadswift.com/api/searches?api_key={$apiKey}"; // Parameters for the search $data = [ 'campaign_id' => 'trà sữa zcat', // Replace with actual campaign ID 'keyword' => '[keyword]', // Replace with the search keyword 'location' => '[location]', // Replace with the search location 'search_html_code' => '[html_code]' // Optional: Replace with the HTML search code, or remove if not needed ]; // Initialize cURL session $ch = curl_init($url); // Set cURL options for the POST request curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); // Execute the request and get the response $response = curl_exec($ch); // Check for errors in the cURL request if ($response === false) { echo 'cURL Error: ' . curl_error($ch); } else { // Print the response from the API echo 'Response: ' . $response; } // Close the cURL session curl_close($ch); exit; // ==================================== // DELETE A SEARCH // ==================================== // API Key $apiKey = '[api_key]'; // ID of the search to be deleted $searchId = '[id]'; // URL for the DELETE request $url = "https://leadswift.com/api/searches/{$searchId}?api_key={$apiKey}"; // Initialize cURL session $ch = curl_init($url); // Set cURL options for the DELETE request curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Execute the request and get the response $response = curl_exec($ch); // Check for errors in the cURL request if ($response === false) { echo 'cURL Error: ' . curl_error($ch); } else { // Print the response from the API echo 'Response: ' . $response; } // Close the cURL session curl_close($ch); exit; // ==================================== // USER INFO, USER PACKAGES // ==================================== // API Key $apiKey = '[api_key]'; // URL for the GET request $url = "https://leadswift.com/api/user_info?api_key={$apiKey}"; // Initialize cURL session $ch = curl_init($url); // Set cURL options for the GET request curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPGET, true); // Execute the request and get the response $response = curl_exec($ch); // Check for errors in the cURL request if ($response === false) { echo 'cURL Error: ' . curl_error($ch); } else { // Print the response from the API echo 'Response: ' . $response; } // Close the cURL session curl_close($ch); exit; // ==================================== // USER SETTINGS // ==================================== // API Key $apiKey = '[api_key]'; // URL for the GET request $url = "https://leadswift.com/api/user_settings?api_key={$apiKey}"; // Initialize cURL session $ch = curl_init($url); // Set cURL options for the GET request curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPGET, true); // Execute the request and get the response $response = curl_exec($ch); // Check for errors in the cURL request if ($response === false) { echo 'cURL Error: ' . curl_error($ch); } else { // Print the response from the API echo 'Response: ' . $response; } // Close the cURL session curl_close($ch); exit; // ==================================== // EDIT USER SETTINGS // ==================================== // API Key $apiKey = '[api_key]'; // URL for the PUT request $url = "https://leadswift.com/api/user_settings?api_key={$apiKey}"; // Parameters for the user settings $data = [ 'notification_email' => '[notification_email]', 'zerobounce_api_key' => '[zerobounce_api_key]', 'neverbounce_api_key' => '[neverbounce_api_key]', 'emaillistverify_api_key' => '[emaillistverify_api_key]', 'mailtester_api_key' => '[mailtester_api_key]', 'hunterio_api_key' => '[hunterio_api_key]', 'debounce_api_key' => '[debounce_api_key]', 'zerobounce_api_enable' => '[zerobounce_api_enable]', 'neverbounce_api_enable' => '[neverbounce_api_enable]', 'emaillistverify_api_enable' => '[emaillistverify_api_enable]', 'mailtester_api_enable' => '[mailtester_api_enable]', 'hunterio_api_enable' => '[hunterio_api_enable]', 'debounce_api_enable' => '[debounce_api_enable]', 'email_verification' => '[email_verification]', 'email_verification_only_email' => '[email_verification_only_email]', 'email_finder' => '[email_finder]', 'disable_notification_email' => '[disable_notification_email]', 'audit_logo' => '[audit_logo]', 'audit_url' => '[audit_url]', 'unsubscribe_url' => '[unsubscribe_url]', 'trackmail_url' => '[trackmail_url]', 'custom_global_blacklist_emails' => '[custom_global_blacklist_emails]', 'maximum_emails_per_business' => '[maximum_emails_per_business]', 'maximum_emails_per_business_export' => '[maximum_emails_per_business_export]', 'auto_update_global_blacklist_emails' => '[auto_update_global_blacklist_emails]', 'smtp' => [ [ 'smtp_id' => '[smtp_id]', 'sender_name' => '[sender_name]', 'smtp_host' => '[smtp_host]', 'smtp_port' => '[smtp_port]', 'smtp_encryption' => '[smtp_encryption]', 'smtp_auth' => '[smtp_auth]', 'smtp_username' => '[smtp_username]', 'smtp_password' => '[smtp_password]', 'email_signature' => '[email_signature]', 'maximum_emails_per_day' => '[maximum_emails_per_day]', 'maximum_emails_per_hour' => '[maximum_emails_per_hour]', 'delay_between_emails' => '[delay_between_emails]', 'delay_after_x_errors' => '[delay_after_x_errors]' ] ] ]; // Convert the data to JSON format $data = http_build_query($data); // Initialize cURL session $ch = curl_init($url); // Set cURL options for the PUT request curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'Content-Length: ' . strlen($data) ]); // Execute the request and get the response $response = curl_exec($ch); // Check for errors in the cURL request if ($response === false) { echo 'cURL Error: ' . curl_error($ch); } else { // Print the response from the API echo 'Response: ' . $response; } // Close the cURL session curl_close($ch); exit; // ==================================== // GET LEADS OF A SEARCH // ==================================== // API Key $apiKey = '[api_key]'; // URL for the POST request $url = "https://leadswift.com/api/leads?api_key={$apiKey}"; $searchId = '[search id]'; $startOffset = 0; // Paging offset, the total offset is returned [recordsFiltered] value $length = 25; // Number of leads per page // Data to be sent with the request $data = [ 'search_id' => $searchId, 'draw' => 1, 'start' => $startOffset, 'length' => $length, 'search' => [ 'value' => '', 'regex' => false ], 'custom_filter' => '', 'exact_match_location' => 0, 'exclude_closed_location' => 0, 'merge_by_domain' => 0, 'exact_match_domain_only' => 0, 'social_profiles' => 0, 'whois' => 0, 'free_providers' => 0, 'cols' => [ 0, 1, 2, 3, 6, 7, 8, 9, 51, 52, 84, 85, 86, 87, 88, 89, 90 ] ]; // Initialize cURL session $ch = curl_init($url); // Set cURL options for the POST request curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Execute the request and get the response $response = curl_exec($ch); // Check for errors in the cURL request if ($response === false) { echo 'cURL Error: ' . curl_error($ch); } else { // Print the response from the API echo 'Response: ' . $response; } // Close the cURL session curl_close($ch); exit; // ==================================== // EXPORT DATA (STEP 1: Begin Export) // ==================================== $beginExportUrl = 'https://leadswift.com/api/export_leads_begin?api_key=' . $apiKey; $searchId = '[search_id]'; // Replace with your actual search ID $export_csv_params = '...'; // Replace with actual POST data from UI /* Example: $export_csv_params = 'export_csv_params=%7B%22draw%22%3A1%2C%22columns%22%3A%5B%7B%22data%22%3A0%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A1%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A2%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A3%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A4%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A5%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A6%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A7%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A8%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A9%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A10%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A11%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A12%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A13%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A14%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A15%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A16%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A17%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A18%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A19%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A20%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A21%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A22%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A23%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A24%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A25%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A26%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A27%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A28%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A29%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A30%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A31%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A32%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A33%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A34%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A35%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A36%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A37%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A38%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A39%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A40%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A41%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A42%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A43%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A44%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A45%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A46%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A47%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A48%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A49%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A50%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A51%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A52%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A53%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A54%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A55%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A56%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A57%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A58%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A59%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A60%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A61%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A62%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A63%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A64%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A65%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A66%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A67%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A68%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A69%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A70%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A71%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A72%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A73%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A74%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A75%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A76%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A77%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A78%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A79%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A80%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A81%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A82%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A83%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A84%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A85%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A86%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A87%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A88%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Afalse%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A89%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%2C%7B%22data%22%3A90%2C%22name%22%3A%22%22%2C%22searchable%22%3Atrue%2C%22orderable%22%3Atrue%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%7D%5D%2C%22order%22%3A%5B%7B%22column%22%3A9%2C%22dir%22%3A%22asc%22%7D%5D%2C%22start%22%3A0%2C%22length%22%3A25%2C%22search%22%3A%7B%22value%22%3A%22%22%2C%22regex%22%3Afalse%7D%2C%22custom_filter%22%3A%22%22%2C%22exact_match_location%22%3A0%2C%22exclude_closed_location%22%3A1%2C%22merge_by_domain%22%3A1%2C%22exact_match_domain_only%22%3A0%2C%22social_profiles%22%3A0%2C%22whois%22%3A0%2C%22free_providers%22%3A0%2C%22cols%22%3A%5B0%2C1%2C2%2C3%2C4%2C6%2C7%2C8%2C9%2C10%2C11%2C12%2C13%2C14%2C15%2C16%2C19%2C20%2C21%2C22%2C23%2C24%2C25%2C26%2C27%2C28%2C29%2C30%2C31%2C32%2C33%2C51%2C52%2C53%2C54%2C55%2C84%2C85%2C87%2C89%2C90%5D%7D&page=0&total_pages=9999&select_lead=&export_include_contact_details=0&remove_duplicates=0&one_contact_per_row=1'; */ $postData = $export_csv_params."&search_id=".$searchId; $ch = curl_init($beginExportUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); $response = curl_exec($ch); if (curl_errno($ch)) { echo 'Error: ' . curl_error($ch); } else { curl_close($ch); $result = json_decode($response, true); if (!empty($result['data'])) { echo "Export started. Use this cron_id to check status later: " . $result['data']; } else { echo "Error starting export: " . $response; } } exit; // ==================================== // EXPORT DATA (STEP 2: Check Status) // ==================================== $exportStatusUrl = 'https://leadswift.com/api/export_leads_status?api_key=' . $apiKey; $cronId = [cron_id]; // Replace with the actual cron_id received above $postData = ['cron_id' => $cronId]; $ch = curl_init($exportStatusUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData)); $response = curl_exec($ch); if (curl_errno($ch)) { echo 'Error: ' . curl_error($ch); } else { curl_close($ch); $status = json_decode($response, true); echo "Export status:
"; print_r($status); } exit; // ==================================== // SAMPLE OF THE EXPORT SCRIPT WITH AUTO CHEKING STATUS AND DOWNLOAD FILE // ==================================== set_time_limit(0); /** * LeadSwift API - Export Leads */ $api_key = '[your_api_key]'; $search_id = [search_id]; // ----------------------------------------------------------------------- // STEP 1: Build export_csv_params as a proper JSON object // ----------------------------------------------------------------------- $col_ids = array(0, 1, 2, 3, 6, 7, 8, 9, 51, 52, 84, 85, 86, 87, 88, 89, 90); $columns = array(); foreach ($col_ids as $col_data) { $columns[] = array( 'data' => $col_data, 'name' => '', 'searchable' => true, 'orderable' => true, 'search' => array( 'value' => '', 'regex' => false, ), ); } $export_csv_params = array( 'draw' => 1, 'columns' => $columns, 'order' => array(array('column' => 4, 'dir' => 'desc')), 'start' => 0, 'length' => 25, 'search' => array('value' => '', 'regex' => false), 'custom_filter' => '', 'exact_match_location' => 0, 'exclude_closed_location' => 0, 'merge_by_domain' => 0, 'exact_match_domain_only' => 0, 'social_profiles' => 0, 'whois' => 0, 'free_providers' => 0, 'cols' => $col_ids, ); // ----------------------------------------------------------------------- // STEP 2: Build the POST body // ----------------------------------------------------------------------- $post_fields = array( 'search_id' => $search_id, 'export_csv_params' => json_encode($export_csv_params), 'page' => 0, 'total_pages' => 9999, 'select_lead' => '', 'export_include_contact_details' => 1, 'remove_duplicates' => 0, 'one_contact_per_row' => 1, ); // ----------------------------------------------------------------------- // STEP 3: POST to export_leads_begin // ----------------------------------------------------------------------- $url = 'https://leadswift.com/api/export_leads_begin?api_key=' . urlencode($api_key); $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_fields)); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $response = curl_exec($ch); $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); echo "HTTP Status: $http_status\n"; echo "Response: $response\n"; $data = json_decode($response, true); if ($http_status !== 200 || empty($data['data'])) { echo "ERROR: Could not start export. Check search_id and api_key.\n"; exit(1); } $cron_id = $data['data']; echo "Export started. cron_id = $cron_id\n"; // ----------------------------------------------------------------------- // STEP 4: Poll export_leads_status until Completed // ----------------------------------------------------------------------- $status_url = 'https://leadswift.com/api/export_leads_status?api_key=' . urlencode($api_key); $max_attempts = 120; $sleep_seconds = 5; for ($i = 1; $i <= $max_attempts; $i++) { sleep($sleep_seconds); $ch = curl_init($status_url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('cron_id' => $cron_id))); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $status_response = curl_exec($ch); curl_close($ch); $status_data = json_decode($status_response, true); $status = isset($status_data['data']['status']) ? $status_data['data']['status'] : 'unknown'; $percent = isset($status_data['data']['completed_percent']) ? $status_data['data']['completed_percent'] : 0; $file_url = isset($status_data['data']['file_download']) ? $status_data['data']['file_download'] : null; echo "Poll $i/$max_attempts - status: $status ($percent%)\n"; if ($status === 'Completed') { if ($file_url) { echo "Export ready! Download URL:\n$file_url\n"; $csv_ch = curl_init($file_url); curl_setopt($csv_ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($csv_ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($csv_ch, CURLOPT_TIMEOUT, 60); $csv_content = curl_exec($csv_ch); curl_close($csv_ch); $filename = 'leads_export_' . $search_id . '_' . date('Ymd_His') . '.csv'; file_put_contents($filename, $csv_content); echo "File saved as: $filename\n"; } else { echo "Status Completed but no file_download in response.\n"; echo "Full response: $status_response\n"; } exit(0); } } echo "Timed out waiting for export to complete after " . ($max_attempts * $sleep_seconds) . " seconds.\n"; exit(1);