Consolibyte Quickbooks PHP SDK (web connector) - Repeated Tasks -


i'm using consolibyte qb sdk found here, , part working well.

however, have situation need check if customers, estimates, , sales orders have been created or updated in quickbooks each time qb reports server. if so, upload new/updated ones server.

i remember seeing scheduled tasks (or repeated tasks, or of nature) in docs, cannot find now.

i don't think want bother quickbooks sql mirroring... seems overkill. can point me in right direction?

here example of how you're describing:

in summary:

register login success hook - function gets called every time web connector starts new sync session.

// array of callback hooks $hooks = array(     quickbooks_webconnector_handlers::hook_loginsuccess => '_quickbooks_hook_loginsuccess',     // call whenever successful login occurs     ); 

https://github.com/consolibyte/quickbooks-php/blob/master/docs/web_connector/example_web_connector_import.php#l126

use function queue request query new.

function _quickbooks_hook_loginsuccess($requestid, $user, $hook, &$err, $hook_data, $callback_config) {     // new users, need set few things     // fetch queue instance     $queue = quickbooks_webconnector_queue_singleton::getinstance();     $date = '1983-01-02 12:01:01';      // same customers     if (!_quickbooks_get_last_run($user, quickbooks_import_customer))     {         _quickbooks_set_last_run($user, quickbooks_import_customer, $date);     }      $queue->enqueue(quickbooks_import_customer, 1, qb_priority_customer); } 

https://github.com/consolibyte/quickbooks-php/blob/master/docs/web_connector/example_web_connector_import.php#l219

write request/response handlers create qbxml query asks modified objects:

function _quickbooks_customer_import_request($requestid, $user, $action, $id, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale) {     // iterator support (break result set small chunks)     $attr_iteratorid = '';     $attr_iterator = ' iterator="start" ';     if (empty($extra['iteratorid']))     {         // first request in new batch         $last = _quickbooks_get_last_run($user, $action);         _quickbooks_set_last_run($user, $action);           // update last run time now()          // set current run $last         _quickbooks_set_current_run($user, $action, $last);     }     else     {         // continuation of batch         $attr_iteratorid = ' iteratorid="' . $extra['iteratorid'] . '" ';         $attr_iterator = ' iterator="continue" ';          $last = _quickbooks_get_current_run($user, $action);     }      // build request     $xml = '<?xml version="1.0" encoding="utf-8"?>         <?qbxml version="' . $version . '"?>         <qbxml>             <qbxmlmsgsrq onerror="stoponerror">                 <customerqueryrq ' . $attr_iterator . ' ' . $attr_iteratorid . ' requestid="' . $requestid . '">                     <maxreturned>20</maxreturned>                     <frommodifieddate>' . $last . '</frommodifieddate>                     <ownerid>0</ownerid>                 </customerqueryrq>               </qbxmlmsgsrq>         </qbxml>';      return $xml; } /**   * handle response quickbooks   */ function _quickbooks_customer_import_response($requestid, $user, $action, $id, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents) {        if (!empty($idents['iteratorremainingcount']))     {         // queue request          $queue = quickbooks_webconnector_queue_singleton::getinstance();         $queue->enqueue(quickbooks_import_customer, null, qb_priority_customer, array( 'iteratorid' => $idents['iteratorid'] ));     }      ... handle xml blob quickbooks here ...       return true; } 

https://github.com/consolibyte/quickbooks-php/blob/master/docs/web_connector/example_web_connector_import.php#l472


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -