我想使用PHP连接到Quickbooks桌面版的数据库。对于这个Iam使用从链接http://consolibyte.com/downloads/quickbooks-php-devkit/下载的PHP开发工具包。 在这里,我使用docs / example_app_web_connector文件夹中的给定代码成功连接到Quickbooks数据库。在其中添加客户到数据库正在工作。但是当我尝试添加从数据库中获取所有员工的功能时,它会显示错误,例如没有注册的操作功能。 我应该在哪里使用此功能才能完美地工作?
在功能页面中,我编码如下: -
function _quickbooks_customer_query_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_QUERY_CUSTOMER, null, 0, array( 'iteratorID' => $idents['iteratorID'] ));
}
// This piece of the response from QuickBooks is now stored in $xml. You
// can process the qbXML response in $xml in any way you like. Save it to
// a file, stuff it in a database, parse it and stuff the records in a
// database, etc. etc. etc.
//
// The following example shows how to use the built-in XML parser to parse
// the response and stuff it into a database.
// Import all of the records
$errnum = 0;
$errmsg = '';
$Parser = new QuickBooks_XML_Parser($xml);
if ($Doc = $Parser->parse($errnum, $errmsg))
{
$Root = $Doc->getRoot();
$List = $Root->getChildAt('QBXML/QBXMLMsgsRs/CustomerQueryRs');
foreach ($List->children() as $Customer)
{
$values = array(
'ListID' => $Customer->getChildDataAt('CustomerRet ListID'),
'FullName' => $Customer->getChildDataAt('CustomerRet FullName'),
'FirstName' => $Customer->getChildDataAt('CustomerRet FirstName'),
'LastName' => $Customer->getChildDataAt('CustomerRet LastName'),
);
print_r($values);
foreach ($Customer->children() as $Node)
{
// Be careful! Custom field names are case sensitive!
if ($Node->name() === 'DataExtRet' and
$Node->getChildDataAt('DataExtRet DataExtName') == 'Your Custom Field Name Goes Here')
{
$values['Your Custom Field Names Goes Here'] = $Node->getChildDataAt('DataExtRet DataExtValue');
}
}
$fullname=$values['FullName'];
$firstname=$values['FirstName'];
$lastname=$values['LastName'];
$listid=$values['ListID'];
// Do something with that data...
mysql_query("INSERT INTO `my_customer_table` (name,fname,lname,quickbooks_listid) VALUES ('$fullname','$firstname','$lastname','$listid') ");
exit;
}
}
return true;
}
在这样的主要代码中 : - require_once dirname( FILE )。 '/config.php';
$Queue = new QuickBooks_WebConnector_Queue($dsn);
$fg=$Queue->enqueue(QUICKBOOKS_QUERY_CUSTOMER);
答案 0 :(得分:1)
抱歉有问题.. atlast得到它...实际上在那个文件夹中,他们是一个名为qbwc.php的文件,我没注意到。在其中我们必须在$ map变量中添加函数...
<?php
require_once dirname(__FILE__) . '/config.php';
/**
* Require some callback functions
*/
require_once dirname(__FILE__) . '/functions.php';
// Map QuickBooks actions to handler functions
$map = array(
QUICKBOOKS_ADD_CUSTOMER => array( '_quickbooks_customer_add_request', '_quickbooks_customer_add_response' ),
QUICKBOOKS_QUERY_CUSTOMER => array( '_quickbooks_customer_query_request', '_quickbooks_customer_query_response' ),
);
// This is entirely optional, use it to trigger actions when an error is returned by QuickBooks
$errmap = array(
'*' => '_quickbooks_error_catchall', // Using a key value of '*' will catch any errors which were not caught by another error handler
);
// An array of callback hooks
$hooks = array(
);
// Logging level
$log_level = QUICKBOOKS_LOG_DEVELOP; // Use this level until you're sure everything works!!!
// What SOAP server you're using
$soapserver = QUICKBOOKS_SOAPSERVER_BUILTIN; // A pure-PHP SOAP server (no PHP ext/soap extension required, also makes debugging easier)
$soap_options = array( // See http://www.php.net/soap
);
$handler_options = array(
'deny_concurrent_logins' => false,
'deny_reallyfast_logins' => false,
); // See the comments in the QuickBooks/Server/Handlers.php file
$driver_options = array( // See the comments in the QuickBooks/Driver/<YOUR DRIVER HERE>.php file ( i.e. 'Mysql.php', etc. )
);
$callback_options = array(
);
// Create a new server and tell it to handle the requests
// __construct($dsn_or_conn, $map, $errmap = array(), $hooks = array(), $log_level = QUICKBOOKS_LOG_NORMAL, $soap = QUICKBOOKS_SOAPSERVER_PHP, $wsdl = QUICKBOOKS_WSDL, $soap_options = array(), $handler_options = array(), $driver_options = array(), $callback_options = array()
$ Server = new QuickBooks_WebConnector_Server($ dsn,$ map,$ errmap,$ hooks,$ log_level,$ soapserver,QUICKBOOKS_WSDL,$ soap_options,$ handler_options,$ driver_options,$ callback_options); $ response = $ Server-&gt; handle(true,true); ?&GT;