2016-11-10 4 views
1

私はConsolibyte QB SDK found hereを使用しています。ほとんどの部分がうまく機能しています。Consolibyte Quickbooks PHP SDK(Webコネクタ) - 繰り返しのタスク

ただし、QBがサーバーに報告するたびにQuickbooksで顧客、見積もり、および受注が作成または更新されているかどうかを確認する必要があります。その場合は、新しい/更新されたものをサーバーにアップロードします。

スケジュールされたタスク(または繰り返したタスクなど)がドキュメントに表示されていましたが、今すぐ見つけることができません。

私はQuickbooks SQL Mirroringを気にしたくないと思います...残酷なようです。誰かが私を正しい方向に向けることができますか?ここで

答えて

2

あなたが記述しているものを行う方法の例です:

要するに

ログイン成功フックを登録する - これは取得する機能ですWeb Connectorが新しい同期セッションを開始するたびに呼び出されます。

// An array of callback hooks 
$hooks = array(
    QuickBooks_WebConnector_Handlers::HOOK_LOGINSUCCESS => '_quickbooks_hook_loginsuccess',  // call this whenever a successful login occurs 
    ); 

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

新しいものを照会するための要求をキューする関数を使用します。

function _quickbooks_hook_loginsuccess($requestID, $user, $hook, &$err, $hook_data, $callback_config) 
{ 
    // For new users, we need to set up a few things 
    // Fetch the queue instance 
    $Queue = QuickBooks_WebConnector_Queue_Singleton::getInstance(); 
    $date = '1983-01-02 12:01:01'; 

    // Do the same for 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

変更されたオブジェクトを要求qbXMLクエリを作成するためにあなたの要求/応答ハンドラを書く:詳細な回答キースため

function _quickbooks_customer_import_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale) 
{ 
    // Iterator support (break the result set into small chunks) 
    $attr_iteratorID = ''; 
    $attr_iterator = ' iterator="Start" '; 
    if (empty($extra['iteratorID'])) 
    { 
     // This is the first request in a new batch 
     $last = _quickbooks_get_last_run($user, $action); 
     _quickbooks_set_last_run($user, $action);   // Update the last run time to NOW() 

     // Set the current run to $last 
     _quickbooks_set_current_run($user, $action, $last); 
    } 
    else 
    { 
     // This is a continuation of a batch 
     $attr_iteratorID = ' iteratorID="' . $extra['iteratorID'] . '" '; 
     $attr_iterator = ' iterator="Continue" '; 

     $last = _quickbooks_get_current_run($user, $action); 
    } 

    // Build the 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 a response from 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 up another request 

     $Queue = QuickBooks_WebConnector_Queue_Singleton::getInstance(); 
     $Queue->enqueue(QUICKBOOKS_IMPORT_CUSTOMER, null, QB_PRIORITY_CUSTOMER, array('iteratorID' => $idents['iteratorID'])); 
    } 

    ... handle the XML blob from QuickBooks here ... 

    return true; 
} 

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

+0

感謝を。まさに私が何をしたのか。 –

+0

問題はない、私は助けることができてうれしい! –

関連する問題