php - Error connecting with QuickBooks Web Connector -
php - Error connecting with QuickBooks Web Connector -
i using keith palmer's quickbooks php devkit connect php pos quickbooks. have installed @ several different installations , have never had issue this. unfortunately else wrote code while back. please help me find what's going wrong one.
after adding application qb webconnector, when trying connect, 'authentication failed' error. entire message below. below qwc file , part of php file connecting to.
error version: not provided service
message: authentication failed
description: qbwc1012: authentication failed due next error message. client found response content type of 'text/html', expected 'text/xml'. request failed error message: -- deprecated: mysql_connect(): mysql extension deprecated , removed in future: utilize mysqli or pdo instead in /home/domaincom/public_html/shop/qbconnector/quickbooks/driver/sql/mysql.php on line 267 deprecated: mysql_connect(): mysql extension deprecated , removed in future: utilize mysqli or pdo instead in /home/domaincom/public_html/shop/qbconnector/quickbooks/driver/sql/mysql.php on line 267 warning: cannot modify header info - headers sent (output started @ /home/domaincom/public_html/shop/qbconnector/quickbooks/driver/sql/mysql.php:267) in /home/domaincom/public_html/shop/qbconnector/quickbooks/webconnector/server.php on line 276 nvu --. see qwclog more details. remember turn logging on.
here qwc file:
<?xml version="1.0"?> <qbwcxml> <appname>quickbooks integrator</appname> <appid></appid> <appurl>https://www.domain.com/shop/qbconnector/qbwc.php </appurl> <appdescription></appdescription> <appsupport>https://www.domain.com/shop/qbconnector/skip_receipt.php</appsupport> <username>quickbooks</username> <ownerid>{90f44fb7-33d9-4815-ac85-ac86a7e7d1eb}</ownerid> <fileid>{5af3b9b6-86f1-4fcc-b1ff-967de1813d20}</fileid> <qbtype>qbfs</qbtype> <scheduler> <runeverynminutes>10</runeverynminutes> </scheduler> <isreadonly>false</isreadonly> </qbwcxml>
and here qbwc.php file point above. allow me know if need more:
<?php // makes debugging bit easier... error_reporting(e_all | e_strict); ini_set('display_errors', 1); // need create sure right timezone set, or php installations complain if (function_exists('date_default_timezone_set')) { // * create sure set right timezone! * see http://us3.php.net/manual/en/timezones.php date_default_timezone_set('america/vancouver'); } // require framework require_once dirname(__file__) . '/quickbooks.php'; // web connector username/password $user = 'quickbooks'; $pass = 'password'; // set connection pcrt database //$dsn = 'mysql://root:sysadmin@localhost/pcrt'; $dsn = 'mysql://dbuser:password@localhost/dbname'; // map quickbooks actions handler functions $map = array( quickbooks_add_invoice => array('_quickbooks_invoice_add_request', '_quickbooks_invoice_add_response'), quickbooks_add_customer => array('_quickbooks_customer_add_request', '_quickbooks_customer_add_response'), quickbooks_add_inventoryitem => array('_quickbooks_inventoryitem_add_request', '_quickbooks_inventoryitem_add_response'), ); // error handlers $errmap = array( 500 => '_quickbooks_error_e500_notfound', // grab errors caused searching things not nowadays in quickbooks 1 => '_quickbooks_error_e500_notfound', '*' => '_quickbooks_error_catchall', // grab other errors might occur ); // array of callback hooks $hooks = array( quickbooks_webconnector_handlers::hook_loginsuccess => '_quickbooks_hook_loginsuccess', // phone call successful login ); // logging level $log_level = quickbooks_log_develop; // soap server you're using $soapserver = quickbooks_soapserver_builtin; // pure-php soap server (no extensions required) // other options $soap_options = array(); $handler_options = array( //'authenticate' => ' *** not need provide configuration variable utilize default authentication method driver you're using (i.e.: mysql) *** ' //'authenticate' => 'your_function_name_here', //'authenticate' => array( 'yourclassname', 'yourstaticmethod' ), 'deny_concurrent_logins' => false, 'deny_reallyfast_logins' => false, ); // see comments in quickbooks/server/handlers.php file $driver_options = array(); $callback_options = array(); // if haven't done our one-time initialization yet, now! if (!quickbooks_utilities::initialized($dsn)) { // initialize creates neccessary database schema queueing requests , logging quickbooks_utilities::initialize($dsn); // creates username , password used web connector authenticate quickbooks_utilities::createuser($dsn, $user, $pass); } quickbooks_webconnector_queue_singleton::initialize($dsn); // create new server , tell handle requests $server = new quickbooks_webconnector_server($dsn, $map, $errmap, $hooks, $log_level, $soapserver, quickbooks_wsdl, $soap_options, $handler_options, $driver_options, $callback_options); $response = $server->handle(true, true); /** * login success hook - perform action when user logs in via web connector * * every time web connector logs in, we're going queue request * import of customers quickbooks. */ function _quickbooks_hook_loginsuccess($requestid, $user, $hook, &$err, $hook_data, $callback_config) { // fetch queue instance $queue = quickbooks_webconnector_queue_singleton::getinstance(); //$queue->enqueue(quickbooks_add_invoice, 1000); $sql = "select r.receipt_id receipts r, sold_items s r.storeid = '1' , r.receipt_id > 4809 , r.receipt_id not in (select distinct q.receipt_id qbinvoices q q.receipt_id = r.receipt_id) , r.receipt_id = s.receipt order r.date_sold desc "; $result = mysql_query($sql); $i = 0; while ($row = mysql_fetch_assoc($result)) { $queue->enqueue(quickbooks_add_invoice, (int) $row["receipt_id"], (int) $i); ++$i; $queue->enqueue(quickbooks_add_inventoryitem, (int) $row["receipt_id"], (int) $i); ++$i; $queue->enqueue(quickbooks_add_customer, (int) $row["receipt_id"], (int) $i); ++$i; //break; } // queue request } /** * build request import customers web store quickbooks */ function _quickbooks_customer_add_request($requestid, $user, $action, $id, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale) { // grab info our mysql database $sql = "select address1, address2, city, zip, email, person_name, phone_number, state, company receipts receipt_id = " . (int) $id; $customer = mysql_fetch_assoc(mysql_query($sql)); $pieces = explode(" ", $customer["person_name"]); $custname = ''; if (count($pieces) > 1) { $custname = '<firstname>' . $pieces[0] . '</firstname> <lastname>' . $pieces[1] . '</lastname>'; } else { $custname = '<firstname>' . $pieces[0] . '</firstname>'; } $xml = '<?xml version="1.0" encoding="utf-8"?> <?qbxml version="2.0"?> <qbxml> <qbxmlmsgsrq onerror="continueonerror"> <customeraddrq requestid="' . $requestid . '"> <customeradd> <name>' . htmlspecialchars($customer["person_name"]) . '</name> <companyname>' . htmlspecialchars($customer["company"]) . '</companyname> ' . $custname . ' <billaddress> <addr1>' . htmlspecialchars($customer["address1"]) . '</addr1> <addr2>' . htmlspecialchars($customer["address2"]) . '</addr2> <city>' . htmlspecialchars($customer["city"]) . '</city> <state>' . htmlspecialchars($customer["state"]) . '</state> <postalcode>' . htmlspecialchars($customer["zip"]) . '</postalcode> <country>canada</country> </billaddress> <phone>' . htmlspecialchars($customer["phone_number"]) . '</phone> <email>' . htmlspecialchars($customer["email"]) . '</email> <contact>' . htmlspecialchars($customer["person_name"]) . '</contact> </customeradd> </customeraddrq> </qbxmlmsgsrq> </qbxml>'; homecoming $xml; } /** * build request import items web store quickbooks */ function _quickbooks_invoice_add_request($requestid, $user, $action, $id, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale) { // grab info our mysql database //$arr = mysql_fetch_assoc(mysql_query("select * my_customer_table id = " . (int) $id)); $sql = "select address1, address2, city, zip, date_sold, email, check_number, grandtax, grandtotal, paywith, pay_type, person_name, phone_number, receipt_id, state receipts receipt_id = " . (int) $id; $arr = mysql_fetch_assoc(mysql_query($sql)); $sql = "select stock_title, labor_desc, sold_type, sold_price, case when taxex = 0 'e' else 'e' end taxex sold_items left bring together stock s on s.stock_id=i.stockid i.receipt=" . (int) $arr["receipt_id"]; $items = mysql_query($sql); $itemxml = ''; while ($item = mysql_fetch_assoc($items)) { $varname = ''; if ($item["sold_type"] == "labor") { //for labor type if (is_null($item["labor_desc"])) { $varname = "labor"; } else { $varname = $item["labor_desc"]; } } else { if (is_null($item["stock_title"])) { $varname = "non-inventory item"; } else { $varname = $item["stock_title"]; } } $itemxml = $itemxml . '<invoicelineadd> <itemref> <fullname>' . htmlspecialchars($varname) . '</fullname> </itemref> <quantity>1.00000</quantity> <rate>' . $item["sold_price"] . '</rate> <salestaxcoderef> <fullname>' . $item["taxex"] . '</fullname> </salestaxcoderef> </invoicelineadd>'; } //print_r($arr); //die(); $tdate = date('y-m-d', strtotime($arr["date_sold"])); //. 't' . date('h:i:s', strtotime($arr["date_sold"])) . 'z'; $xml = '<?xml version="1.0" encoding="utf-8"?> <?qbxml version="5.0"?> <qbxml> <qbxmlmsgsrq onerror="continueonerror"> <invoiceaddrq requestid="' . $requestid . '"> <invoiceadd> <customerref> <fullname>' . htmlspecialchars($arr["person_name"]) . '</fullname> </customerref> <txndate>' . $tdate . '</txndate> <billaddress> <addr1>' . htmlspecialchars($arr["address1"]) . '</addr1> <addr2>' . htmlspecialchars($arr["address2"]) . '</addr2> <addr3 /> <city>' . htmlspecialchars($arr["city"]) . '</city> <state>' . htmlspecialchars($arr["state"]) . '</state> <postalcode>' . htmlspecialchars($arr["zip"]) . '</postalcode> <country>canada</country> </billaddress> <shipaddress> <addr1>' . htmlspecialchars($arr["address1"]) . '</addr1> <addr2>' . htmlspecialchars($arr["address2"]) . '</addr2> <addr3 /> <city>' . htmlspecialchars($arr["city"]) . '</city> <state>' . htmlspecialchars($arr["state"]) . '</state> <postalcode>' . htmlspecialchars($arr["zip"]) . '</postalcode> <country>canada</country> </shipaddress> <memo>imported pcrt</memo> ' . $itemxml . ' </invoiceadd> </invoiceaddrq> </qbxmlmsgsrq> </qbxml>'; homecoming $xml; } /** * build request import invoice web store quickbooks */ function _quickbooks_inventoryitem_add_request($requestid, $user, $action, $id, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale) { // grab info our mysql database $sql = "select stock_title, labor_desc, sold_type, sold_price, case when taxex = 0 'e' else 'e' end taxex sold_items left bring together stock s on s.stock_id=i.stockid i.receipt=" . (int) $id; $items = mysql_query($sql); $itemxml = '<?xml version="1.0" encoding="utf-8"?> <?qbxml version="7.0"?> <qbxml> <qbxmlmsgsrq onerror="continueonerror">'; $varname = ''; while ($item = mysql_fetch_assoc($items)) { if ($item["sold_type"] == "labor") { //for labor type create service item if (is_null($item["labor_desc"])) { $varname = "labor"; } else { $varname = $item["labor_desc"]; } $varnametrim = substr($varname,0,31); $itemxml = $itemxml . ' <itemserviceaddrq requestid="' . $requestid . '" > <itemserviceadd> <name>' . htmlspecialchars($varnametrim) . '</name> <salesorpurchase> <desc>' . htmlspecialchars($varname) . ' </desc> <price>' . htmlspecialchars($item["sold_price"]) . '</price> <accountref> <fullname>sales - unsorted</fullname> </accountref> </salesorpurchase> </itemserviceadd> </itemserviceaddrq>'; // </qbxmlmsgsrq> // </qbxml>'; } else { //if ($item["sold_type"] == "labor") //for labor type create service item if (is_null($item["stock_title"])) { $varname = "non-inventory item"; } else { $varname = $item["stock_title"]; } $varnametrim = substr($varname,0,31); // inventory item - alter incomeaccountref, cogsaccountref , assetaccountref // $itemxml = $itemxml . ' <iteminventoryaddrq requestid="' . $requestid . '" > // <iteminventoryadd> // <name>' . $varnametrim . '</name> // <salesdesc>' . $varname . ' - auto-added pcrt quickbooks integrator</salesdesc> // <salesprice>' . $item["sold_price"] . '</salesprice> // <incomeaccountref> // <fullname>sales</fullname> // </incomeaccountref> // <cogsaccountref> // <fullname>cost of goods sold</fullname> // </cogsaccountref> // <assetaccountref> // <fullname>inventory assets</fullname> // </assetaccountref> // </iteminventoryadd> // </iteminventoryaddrq>'; ////this non_inventory item $itemxml = $itemxml . '<itemnoninventoryaddrq requestid="' . $requestid . '" > <itemnoninventoryadd> <name>' . htmlspecialchars($varnametrim) . '</name> <salesorpurchase> <desc>' . htmlspecialchars($varname) . ' - auto-added pcrt quickbooks integrator</desc> <price>' . htmlspecialchars($item["sold_price"]) . '</price> <accountref> <fullname>sales - unsorted</fullname> </accountref> </salesorpurchase> </itemnoninventoryadd> </itemnoninventoryaddrq>'; } } $itemxml = $itemxml . '</qbxmlmsgsrq> </qbxml>'; homecoming $itemxml; } /** * receive response quickbooks */ function _quickbooks_invoice_add_response($requestid, $user, $action, $id, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents) { mysql_query(" insert qbinvoices (receipt_id,qb_listid,qb_editsequence) values( " . (int) $id . "," . (int) $idents['listid'] . "," . (int) $idents['editsequence'] . ")"); // return; } function _quickbooks_customer_add_response($requestid, $user, $action, $id, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents) { // return; } function _quickbooks_inventoryitem_add_response($requestid, $user, $action, $id, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents) { // return; } /** * handle 500 not found error quickbooks * * instead of returning empty result sets queries don't find * records, quickbooks returns error message. handles error * messages, , acts on them adding missing item quickbooks. */ function _quickbooks_error_e500_notfound($requestid, $user, $action, $id, $extra, &$err, $xml, $errnum, $errmsg) { // if ($action == quickbooks_add_invoice) { // homecoming true; // } if ($err == 3200) { homecoming true; } homecoming false; } /** * grab errors occur * * @param string $requestid * @param string $action * @param mixed $id * @param mixed $extra * @param string $err * @param string $xml * @param mixed $errnum * @param string $errmsg * @return void */ function _quickbooks_error_catchall($requestid, $user, $action, $id, $extra, &$err, $xml, $errnum, $errmsg) { $message = ''; $message .= 'request id: ' . $requestid . "\r\n"; $message .= 'user: ' . $user . "\r\n"; $message .= 'action: ' . $action . "\r\n"; $message .= 'id: ' . $id . "\r\n"; $message .= 'extra: ' . print_r($extra, true) . "\r\n"; //$message .= 'error: ' . $err . "\r\n"; $message .= 'error number: ' . $errnum . "\r\n"; $message .= 'error message: ' . $errmsg . "\r\n"; // handle error // mail( ... ); if ($errnum == 3100) { homecoming true; } homecoming false; }
anytime see this:
description: qbwc1012: authentication failed due next error message. client found response content type of 'text/html', expected 'text/xml'.
you know it's sort of php or sql error.
in case, it's php error:
deprecated: mysql_connect(): mysql extension deprecated , removed in future: utilize mysqli or pdo instead in
which telling mysql
extension in php deprecated, , need utilize mysqli
instead.
so, in code here:
$dsn = 'mysql://dbuser:password@localhost/dbname';
just alter mysql
mysqli
, you'll go:
$dsn = 'mysqli://dbuser:password@localhost/dbname';
php soap quickbooks
Comments
Post a Comment