0

I've been trying to sync QB-Web Connector but I keep receiving errors:

The first was: 'Fatal error: Class 'QuickBooks_Loader' not found', which I fixed by adding including the file location at the top of the page: include_once("$_SERVER[DOCUMENT_ROOT]/qb/QuickBooks/Loader.php");

Now I am getting the following error from the web-connector:

QBWC1012: Authentication failed due to following error message. Client found response content type of 'text/html', but expected 'text/xml'. The request failed with an empty response. See QWCLog for more details. Remember to turn logging on.

I checked all the files to be sure that the content type is text/xml, still no dice. Please help.

<?php

/**
 * Example of generating QuickBooks *.QWC files 
 * 
 * @author Keith Palmer <keith@consolibyte.com>
 * 
 * @package QuickBooks
 * @subpackage Documentation
 */

// Error reporting... 
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);

/**
 * Require the utilities class
 */
require_once '../QuickBooks.php';

$name = 'My QuickBooks SOAP Server';                // A name for your server (make it whatever you want)
$descrip = 'An example QuickBooks SOAP Server';     // A description of your server 

$appurl = 'https://www.domain.com/qb/QuickBooks/SOAP/Server.php';       // This *must* be httpS:// (path to your QuickBooks SOAP server)
$appsupport = 'https://www.domain.com';         // This *must* be httpS:// and the domain name must match the domain name above

$username = '';     // This is the username you stored in the 'quickbooks_user' table by using QuickBooks_Utilities::createUser()

$fileid = '57F3B9B6-86F1-4FCC-B1FF-966DE1813D20';       // Just make this up, but make sure it keeps that format
$ownerid = '57F3B9B6-86F1-4FCC-B1FF-166DE1813D20';      // Just make this up, but make sure it keeps that format

$qbtype = QUICKBOOKS_TYPE_QBFS; // You can leave this as-is unless you're using QuickBooks POS

$readonly = false; // No, we want to write data to QuickBooks

$run_every_n_seconds = 600; // Run every 600 seconds (10 minutes)

// Generate the XML file
$QWC = new QuickBooks_WebConnector_QWC($name, $descrip, $appurl, $appsupport, $username, $fileid, $ownerid, $qbtype, $readonly, $run_every_n_seconds);
$xml = $QWC->generate();

// Send as a file download
header('Content-type: text/xml');
header('Content-Disposition: attachment; filename="my-quickbooks-wc-file.qwc"');
print($xml);
exit;
JohnB
  • 1,231
  • 1
  • 18
  • 33

1 Answers1

0

The URL you're using:

$appurl = 'https://www.domain.com/qb/QuickBooks/SOAP/Server.php';

Is not the right URL.

If you reference the quick start guide you'll note that it has to point the Web Connector to this script:

docs/example_web_connector.php

That is the script that should be in your AppURL. The example script is an actual SOAP endpoint which will allow connections from the Web Connector. You've instead pointed the Web Connector to one of the library files which does nothing on it's own, and which you shouldn't need to touch or reference anywhere.

Incidentally, this is also the reason you've had to add that include_once line as well - you won't need that if you have the Web Connector pointed to the right place.

Keith Palmer Jr.
  • 27,666
  • 16
  • 68
  • 105
  • Awesome! That fixed the last error. I'm getting a different set of errors now: Client found response content type of 'text/html', but expected 'text/xml'. The request failed with the error message: -- Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in domain.com/qb/QuickBooks/Driver/Sql/Mysql.php on line 289 host: domain.com, user: user, pass: xxxx, mysql_error(): Lost connection to MySQL server at 'reading initial communication packet', system error: 111 – user2675057 Feb 07 '14 at 04:40
  • Are you sure your database connection string is correct? If you've changed anything in the code beyond just $dsn, please post your code. Are you able to use mysql_connect() to connect to that database, or do you get the same errors when you try to do that? – Keith Palmer Jr. Feb 07 '14 at 04:57
  • @KeithPalmerJr. I am facing the same issue. I have not changed any thing in the example_web_connector.php not even the $dsn value. $dsn = 'mysql://root:root@localhost/quickbooks_server' I have created a database as quickbooks_server on my localhost. I am getting following error host: localhost, user: root, pass: XXXX, mysql_error(): Access denied for user 'root'@'localhost' (using password: YES). I am thinking why it's using password when my local MySQL setup do not need a password. – Saurabh Dec 06 '15 at 09:35
  • @Saurabh You're using the wrong database username and password. Change $dsn so that you're using the correct username and password. – Keith Palmer Jr. Dec 07 '15 at 11:52