问题
I am currently in the process of integrating my php website with the desktop version of Quickbooks. The application resides on a remote computer and will need to remain in sync with the mysql db on my server. After a great deal of research it appears my two options are:
- Use the PHP Devkit and the web connector to accomplish this.
- Manually export csv files periodically from quickbooks and parse them and insert the data into my mysql db.
In regards to the first option, I can't seem to find any resources indicating that it's possible to query all items from the quickbooks db. This would be ideal as I could periodically query the remote quickbooks application for all items and insert ones which have been added/updated. It looks like the xml requests for querying require you to specify the item your querying. This will not work for what I have envisioned. As we are not making any orders from the website and only displaying current items/customers maybe the web connector is not what I need.
This brings me to my next option, manually parsing csv files from the application. I don't mind this as its more straight forward than setting up the php dev kit to talk to the web connector but requires manual intervention to export data files from quickbooks.
Does anyone have experience in accomplishing this task/automating the syncing of data between quickbooks desktop and a remote php website?
Any and all comments/suggestions are appreciated, Thanks.
回答1:
In regards to the first option, I can't seem to find any resources indicating that it's possible to query all items from the quickbooks db.
This is definitely very do-able.
Here's a full blown example of doing it:
- https://github.com/consolibyte/quickbooks-php/blob/master/docs/web_connector/example_web_connector_import.php
(that example can also import all invoices, all customers, etc. - but you could slim it down if you wanted to just do items)
It looks like the xml requests for querying require you to specify the item your querying.
No, they do not require that you specify an item. You can choose to filter things or not.
See the full syntax reference here:
- https://developer-static.intuit.com/qbSDK-current/Common/newOSR/index.html
If you look up ItemQuery, you can specify an item name if you want... or if you don't want to specify any criteria at all, that's fine too. If you specify a name to filter by, it filters items by that. If you don't specify any filters, you get back everything.
This brings me to my next option, manually parsing csv files from the application.
Yuck. :-)
Does anyone have experience in accomplishing this task/automating the syncing of data between quickbooks desktop and a remote php website?
Yes, lots. It's not terribly difficult.
Follow the quick-start guide but substitute the _import.php script instead since you want to import data to MySQL instead of add/update stuff in QuickBooks:
- http://www.consolibyte.com/docs/index.php/PHP_DevKit_for_QuickBooks_-_Quick-Start
If you follow the quick-start you should be up and running within a half-hour. We have support forums too:
- http://consolibyte.com/forum/
回答2:
It's not a massively difficult process once you wrap your head around how the connection works.
In most other web connections of this type, you would sit some code on the machine that can access your quickbooks db (a machine on your network with an open port for queries) you would then send requests to that machine for information, it would query the db and send a response. This would work using a REST API or a SOAP.
Quickbooks does this the other way round, the connector sits on the machine with quickbooks and is pointed at your webserver app, it then constantly asks your app for something to do. Your app verifies who it is, then the connector asks what your app wants and delivers the data based on the response. It's a little about-face but there are some good technical reasons for it.
You can query any part of your quickbooks db so how I would do it is like this.
- Customer arrives at your website and logs in
- Customer asks for information
- Your app responds to the web connector (which frankly has been bugging it for AGES by now)
- Your app asks the web connector for anything that might have been updated regarding the info the customer wants (timestamps are important here)
- Web connector sends that information
- Your app updates it's local db and displays the information
You can modify those steps in terms of you could get your app to update ALL records using a cron job or windows task every hour/day etc but that would mean sometimes the data is not entirely up-to-date and your server would be very busy every time it runs the update.
How you go about it would depend on how much use your are getting to your app. For instance for a high usage app I have a server to show the site, a db server to host the db for the site and server that does nothing but update the db server every couple of hours. I do this by locking records off while updating and making sure the customer cannot change anything directly (I use a batch update job that sends data back to quickbooks).
I hope this (very brief) summary helps and I have provided some links below that have helped me.
Web Connector Wiki, a very good resource for how to set up the web connector
A similar question someone already asked, it was answered by the Web Connect developer
来源:https://stackoverflow.com/questions/23049839/quickbooks-php-devkit