InfusionAPI call ORDER BY specific fields works, with a little finagling.  As usual, the InfusionSoft API documentation is spotty, but reverse engineering its PHP SDK, I found the “dsQueryOrderBy()” method in the InfusionSoft API, even though the documentation has it as dsQueryWithOrderBy() which you will find 500’s with “method does not exist”.  Remove “with” and presto, works like a charm!

public function fetchLatestInfusionList($limit=300,$page=0,$orderBy='LastUpdated',$ascBool=false){
    *  This will look through InfusionSoft to check for records that were most recently added that weren't sync'd with MailChimp
    *  ordered by most recent
    *  $ascBool = true ASC, false DESC
    *  $returnFields = array('Id','ShipFirstName', 'ShipLastName');
       $query = array('DateCreated' => $date);
       $jobs = $app->dsQuery("Job", 10, 0, $query, $returnFields);
    * $results = $app->dsQueryWithOrderBy(
               'Contact', 10, 0,
               array('FirstName' => 'A%'),


   // First, get a list of the last 300 contacts added to InfusionSoft without a 'externalSyncDate' field
   $query = array('_externalSyncDate'=>'~null~');
   $returnFields = array('Id','FirstName','LastName','Email','Phone1','City','State','PostalCode');

   $results = $this->infObj->dsQueryOrderBy(
            'Contact', $limit, $page,
            $orderBy,$ascBool);   // false here is DESC since true is ASC for this query

   return $results;
   // InfusionSoft contacts NOT in Mail Chimp are priority, then updating contacts is second


Use the results to capture the latest contacts imported into InfusionSoft so you can synchronize only the contact records that would be missing and automatically pass these results into other platforms you use, like My Emma or Mail Chimp.  To make things even more effective, create a new field called “externalSyncDate” that you can then use to track and mark when the record was synchronized last to your external platforms so you can avoid repeatedly sending the same records to your API.  This is a very efficient way to only touch records that require synchronization, using InfusionSoft’s custom fields as the database to log those synchronization actions within each contact record.  Make that CRM earn its money, after all, you’re overpaying for it, right?

Any organizations/businesses in the Jacksonville Northeast Florida area looking for open source PHP web developers with experience in Symfony, Drupal, WordPress, Magento, or API integration experts, please contact me.  I have a list of competent web developers who I can recommend here in Jacksonville, Southwest Florida, and throughout the US, Canada, UK, Australia, and Germany as temporary web development consultants or remote web developers!