/** * Retrieves the lists via Infusionsoft API and updates the data in DB. * @return string */ function get_infusionsoft_lists($app_id, $api_key, $name) { if (!function_exists('curl_init')) { return __('curl_init is not defined ', 'rapidology'); } if (!class_exists('iSDK')) { require_once RAD_RAPIDOLOGY_PLUGIN_DIR . 'subscription/infusionsoft/isdk.php'; } $lists = array(); try { $infusion_app = new iSDK(); $infusion_app->cfgCon($app_id, $api_key, 'throw'); } catch (iSDKException $e) { $error_message = $e->getMessage(); } if (empty($error_message)) { $need_request = true; $page = 0; $all_lists = array(); while (true == $need_request) { $error_message = 'success'; $lists_data = $infusion_app->dsQuery('ContactGroup', 1000, $page, array('Id' => '%'), array('Id', 'GroupName')); $all_lists = array_merge($all_lists, $lists_data); if (1000 > count($lists_data)) { $need_request = false; } else { $page++; } } } if (!empty($all_lists)) { foreach ($all_lists as $list) { $group_query = '%' . $list['Id'] . '%'; $subscribers_count = $infusion_app->dsCount('Contact', array('Groups' => $group_query)); $lists[$list['Id']]['name'] = sanitize_text_field($list['GroupName']); $lists[$list['Id']]['subscribers_count'] = sanitize_text_field($subscribers_count); $lists[$list['Id']]['growth_week'] = sanitize_text_field($this->calculate_growth_rate('infusionsoft_' . $list['Id'])); } $this->update_account('infusionsoft', sanitize_text_field($name), array('lists' => $lists, 'api_key' => sanitize_text_field($api_key), 'client_id' => sanitize_text_field($app_id), 'is_authorized' => 'true')); } return $error_message; }
$prodcount = 0; $concount = 0; $found = false; $sel = -1; /****************************************************************************** * * Pre-load all data that is necessary for comparisons to determine if an item * already exists within the Infusionsoft app. * * Example : Load all product id's to compare with products being read so that * we don't create duplicates of the exact same information * *****************************************************************************/ // here we're doing the same thing as above but for the contact's records // how many rows in ContactGroup table $count = $app->dsCount($tName, $query); // iterate all rows of table while ($count > 0) { $data = $app->dsQuery($tName, $limit, $page, $query, $rFields); foreach ($data as $dat) { $ekmcons[$concount] = $dat['Email']; $ekmids[$concount] = $dat['Id']; } $count = $count - 1000; $page++; } $concount = $app->dsCount($tName, $query); /*$data=$app->dsQuery($tName, $limit, $page, $query, $rFields); $count=count($data); foreach ($data as $dat){ $ekmcons[$concount]=$dat['Email'];
<?php require_once "../src/isdk.php"; $app = new iSDK(); echo "created object!<br/>"; if ($app->cfgCon("connectionName")) { echo "app connected!<br/>"; $email = '*****@*****.**'; $totalRecords = $app->dsCount("Contact", array('Email' => $email)); echo $totalRecords; if ($totalRecords > 0) { $totalPages = ceil($totalRecords / 1000); $contacts = array(); $page = 0; do { $contact = $app->dsQuery("Contact", 1000, $page++, array('Email' => $email), array('Id', 'FirstName', 'LastName', 'Email', 'Phone1')); foreach ($contact as $c) { $contacts[] = $c; } } while ($page < $totalPages); echo "<pre>"; print_r($contacts); echo "</pre>"; } else { echo "There were no contacts found with the specified email"; } } else { echo "connection failed!<br/>"; }