For this we needed to use Intuit's Partner Platform and their SDK. Unfortunately, they don't have a set of libraries for PHP, but since the IPP now allows oauth and XML, it is not too hard to integrate. Still, there are dozens of object types and thousands of properties that we need to build in, and that's very time consuming.
So along comes a new version of Keith Palmer's excellent PHP-DevKit. Which finally supports oauth. The problem is, it's not immediately obvious how to use it. Below is a step by step guide:
1. Download the latest devkit build. Unfortunately, its currently only available via SVN, so you'll have to install an SVN client and point it to this url:
svn checkout https://code.intuit.com/svn/repos/php_devkit
2.To create our simple app, we put it on a test server in our /var/www directory. You should now have a file Quickbooks.php and a sub-directory Quickbooks under /var/www
3. Make sure you have mcrypt installed in PHP, you can check this with phpinfo(). If not, download and install it.
4. Make a new file index.php and put the following in the file:
require_once 'QuickBooks.php'; $token = 'sfewtw4et3w45sfsfsdfdsf'; $oauth_consumer_key = 'sfewtwsetsgsdsdfsdc'; $oauth_consumer_secret = 'dsffwe5tr4w5sdfsdfsdfsdfsdf'; // This is the URL of your OAuth auth handler page $this_url = 'http://myserver/index.php'; // This is the URL to forward the user to after they have connected to IPP/IDS via OAuth $that_url = 'http://myserver/other.php'; $dsn = 'mysql://test:test@localhost/quickbooks'; // You should set this to an encryption key specific to your app $encryption_key = 'abcd1234'; // The user that's logged in $the_username = 'your_app_username_here_2'; // The tenant that user is accessing within your own app $the_tenant = 12345;
if (!QuickBooks_Utilities::initialized($dsn)) { // Initialize creates the neccessary database schema for queueing up requests and logging QuickBooks_Utilities::initialize($dsn); } $IntuitAnywhere = new QuickBooks_IPP_IntuitAnywhere($dsn, $encryption_key, $oauth_consumer_key, $oauth_consumer_secret, $this_url, $that_url); if ($IntuitAnywhere->handle($the_username, $the_tenant)) { ; // The user has been connected, and will be redirected to $that_url automatically. } else { die('Oh no, something bad happened: ' . $IntuitAnywhere->errorNumber() . ': ' . $IntuitAnywhere->errorMessage()); }
Let's also make a file called other.php
require_once 'QuickBooks.php'; $token = 'sfewtw4et3w45sfsfsdfdsf'; $oauth_consumer_key = 'sfewtwsetsgsdsdfsdc'; $oauth_consumer_secret = 'dsffwe5tr4w5sdfsdfsdfsdfsdf'; // This is the URL of your OAuth auth handler page $this_url = 'http://myserver/index.php'; // This is the URL to forward the user to after they have connected to IPP/IDS via OAuth $that_url = 'http://myserver/other.php'; $dsn = 'mysql://test:test@localhost/quickbooks'; // You should set this to an encryption key specific to your app $encryption_key = 'abcd1234'; // The user that's logged in $the_username = 'your_app_username_here_2'; // The tenant that user is accessing within your own app $the_tenant = 12345;
if (!QuickBooks_Utilities::initialized($dsn)) { // Initialize creates the neccessary database schema for queueing up requests and logging QuickBooks_Utilities::initialize($dsn); }
// Set up the IPP instance $IPP = new QuickBooks_IPP($dsn); // Set up our IntuitAnywhere instance $IntuitAnywhere = new QuickBooks_IPP_IntuitAnywhere($dsn, $encryption_key, $oauth_consumer_key, $oauth_consumer_secret); // Get our OAuth credentials from the database $creds = $IntuitAnywhere->load($the_username, $the_tenant); // Tell the framework to load some data from the OAuth store $IPP->authMode( QuickBooks_IPP::AUTHMODE_OAUTH, $the_username, $creds); // Print the credentials we're using print_r($creds); // This is our current realm $realm = $creds['qb_realm']; // Load the OAuth information from the database if ($Context = $IPP->context()) { // Set the DBID $IPP->dbid($Context, 'something'); // Set the IPP flavor $IPP->flavor($creds['qb_flavor']); // Get the base URL if it's QBO if ($creds['qb_flavor'] == QuickBooks_IPP_IDS::FLAVOR_ONLINE) { $IPP->baseURL($IPP->getBaseURL($Context, $realm)); } print('Base URL is [' . $IPP->baseURL() . ']' . "\n\n"); $CustomerService = new QuickBooks_IPP_Service_Customer(); $perpage = 3; for ($page = 1; $page <= 3; $page++) { print('PAGE ' . $page . "\n\n"); $list = $CustomerService->findAll($Context, $realm, null, null, $page, $perpage); foreach ($list as $Customer) { print('Name [' . $Customer->getName() . ']' . "\n\n"); } print("\n\n\n"); } print("\n\n\n\n"); print('Request [' . $IPP->lastRequest() . ']'); print("\n\n\n\n"); print('Response [' . $IPP->lastResponse() . ']'); print("\n\n\n\n"); } else { die('Unable to load a context...?'); }
5. Now, a little aside on how oauth works with PHP-DevKit -
- The first request is made by the original php page (in our case index.php - but you can specify whatever you want in $this_url) to the oauth server with your oauth consumer secret and and oauth consumer key (I'll tell you how to get those in a sec). This is done by the handle() function in the IntuitAnywhere object.
- The handle() function then redirects the user to the authentication URL, which shows one of those login/connect screens to the user (like you see when you use a Twitter app).
- Once the user accepts the app, Intuit sends the user back to the page they were on (it will return to whatever is in $this_url -- in our case index.php). This time the handle() function sees that there is a token in the HTTP request and saves the token. It then redirects the user to another page ($that_url, or in our case other.php).
- In other.php, we re-initialize the IntuitAnywhere object, but instead of using handle() to get the token, we use load() to load the token that was saved in the previous step.
- We then create an IPP object specifying that we're using oauth, and that will provide us with a context from which to make calls.
7. Replace myserver (marked in green) in both files to your server URL. Also update the Mysql username and password (marked in blue) to yours
8. Create a database in mysql called quickbooks. This will be used to save tokens. All the tables will be created automatically by PHP Devkit.
9. That's it - now point your browser to http://myserver/index.php - it should redirect to the Intuit Anywhere authorization screen. Users can enter their username and password there and click to authorize your app. Once they do, it will go to other.php and you should see a list of customers for that user.
Hopefully this makes oauth with devkit a bit easier to get started.
hi,
ReplyDeletei am confused on where to get the value for $the_tenant variable...please help...
thanks in advance...
Appguppy: How To Use Keith Palmer'S Php-Devkit To Integrate A Web App With Quickbooks Online >>>>> Download Now
Delete>>>>> Download Full
Appguppy: How To Use Keith Palmer'S Php-Devkit To Integrate A Web App With Quickbooks Online >>>>> Download LINK
>>>>> Download Now
Appguppy: How To Use Keith Palmer'S Php-Devkit To Integrate A Web App With Quickbooks Online >>>>> Download Full
>>>>> Download LINK Ev
Raymond- the $the_tenant variable is something YOU provide- it's your OWN unique identifier for that particular customer/tenant of your web application.
ReplyDeletee.g. if you identify your customers with a unique #, then put your unique customer # there. If you identify them with a domain name (e.g. "their-company.your-website.com") then you could pass in their subdomain.
hi,
ReplyDeleteI am confused where will configure the $the_tenant value for my customers?
Hi Raymond- did you read my comment above and look at the example code? All you have to do is set the $the_tenant variable to your unique identifier for your customer (e.g. your customer ID or customer primary key value). If you look in the example files, it's set in the example_ipp_config.php file.
ReplyDeleteLooks like I get a
ReplyDeleteError Code: internal_error
Message: Error getting application from request token
error when visiting index.php... I can't seem to figure it out! Any suggestions?
Egavas - please use our FORUMS for support:
ReplyDelete* https://idnforums.intuit.com/
OR
* http://www.consolibyte.com/forum/
You will have to post your code so we know what you're doing.
I am getting error "Fatal error: Class 'QuickBooks_IPP_IntuitAnywhere' not found"
ReplyDeletePlease help me out.
Thanks in advance!!!
Pawanvir - if you're having trouble, you should post on the forums. The forums are the best avenue for technical support. http://www.consolibyte.com/forum/ You should consider posting your code so that we can see what you're doing.
ReplyDelete- Keith
Hi Keith
ReplyDeleteThanks for replying. I will have Pawanvir to show the code. However i would like to know your views as what we are trying to achieve is possible.
We are using core php to create our custom shopping cart and trying to connect it to clients QuickBooks Software. However we never used quickbooks. I read on some forums that it will be done through some web connector, however they are asp.net based. Pl. advise if the solutions is still possible in php and what will be the steps involved.
Thanks
Vikram
www.antechindia.com
Vikram,
ReplyDeleteIf you are building a custom, one-off shopping cart *for a single customer* then you should be using the Web Connector, not IPP. Again, post on our forums or the Intuit forums if you need more details.
If you are building an SaaS application which allows many of your end-users to connect their QuickBooks files to your app, and you charge a recurring fee for it, then Intuit Anywhere is the appropriate choice.
Also - the Web Connector is completely language agnostic, since it communicates via SOAP. Thus, the fact that they are ASP.NET based has absolutely no bearing on anything what-so-ever.
ReplyDeleteHI,
ReplyDeleteI have added the customer trough the API(example_ipp_ids_add.php).
I also get response with customer added-{NG-5330401}.
But i am unable to view the customer at https://appcenter.intuit.com/Home/DevHome
Prakash - PLEASE USE OUR FORUMS FOR SUPPORT:
ReplyDelete* https://idnforums.intuit.com/
OR
* http://www.consolibyte.com/forum/
You will have to post your code so we know what you're doing.
Perfect tutorial for beginners to connect to QB.
ReplyDeleteIn order to install mycrypt on Mac, please visit the following link:-
ReplyDeletehttp://www.coolestguyplanettech.com/how-to-install-mcrypt-for-php-on-mac-osx-lion-10-7-development-server/
Hi
ReplyDeletephp_devkit gives error in Aes.php as like
Notice: unserialize() [function.unserialize]: Error at offset 0 of 78 bytes in
Please give the solution of it
Santosh - PLEASE USE OUR FORUMS FOR SUPPORT:
ReplyDelete* https://idnforums.intuit.com/
OR
* http://www.consolibyte.com/forum/
You will have to post your code so we know what you're doing.
Hi
ReplyDeletei download code :
php_devkit
now i cant understand how to start set up code or how to use this code??
what i need to do that i make a one online shopping cart system. when customer purchase order than invoice also generate in quickbook... i need a quickbook online so can u pls help me or guide me how to do???
POST ON THE FORUMS IF YOU NEED SUPPORT. THIS IS NOT AN APPROPRIATE AVENUE FOR GETTING SUPPORT.
ReplyDelete* https://idnforums.intuit.com/
OR
* http://www.consolibyte.com/forum/
You will have to post your code so we know what you're doing.
Hi Keith,
ReplyDeleteI have also integrated this code in my application. But I am not able getting any customer details. Please tell me what we have to input in "$encryption_key" variable and "$the_tenant" variable.
Waiting for your response.
Thanks!
*** IF YOU NEED SUPPORT, YOU NEED TO ASK ON THE FORUMS: http://www.consolibyte.com/forum/ ***
ReplyDeleteIf you ask on the forums, you will get a prompt, detailed response. I can NOT provide support via this comment board thing.
- Keith
Hi Keith,
ReplyDeleteI am just asking only what value we have to pass for these 2 variables.
Thanks!
Look, I'm not trying to be mean here - the bottom line is just that this comment board is just not a good way to provide support. Comments posted on this blog aren't searchable, they mangle code snippets, they aren't separated into relevant topics, and the answers posted here just generally don't benefit the community as a whole, because very few people are going to see the comments here.
ReplyDeleteFor that reason, we don't provide support via this board.
If you want support, PLEASE PLEASE PLEASE ask on the forums. We're a small open-source project team, and we simply can't waste our time answering your questions here when all they do is make a mess of everything we say. If you at all value our contributions to the open-source community, please be appreciative of that and ask your questions on the forums.
Buy Youtube Subscribers
ReplyDeleteBeautiful sentences, words succinct, the story theme anacreontic, the article development is very curious feeling
I have gone through the url that you have mentioned (http://www.consolibyte.com/forum/),
ReplyDeletebut it was saying BLOCKED..!
i am very much in need of integrating QB Online..!
Can you help me over this issue pelase...!
Lucki - if you get that message, it also shows you an e-mail address to email and your IP address. Send an email to that address with your IP address, and we'll unblock you. It's likely because someone was/is using your IP to send SPAM.
DeleteThis comment has been removed by the author.
DeleteThis comment has been removed by the author.
DeleteHi Keith,
ReplyDeleteI know posting here is absurd, but i was stuck with the issue and i could not access (http://www.consolibyte.com/forum/),
I am having an issue,
Fatal error: Class 'OAuth' not found in D:\wamp\www\QB\Core\RestCalls\SyncRestHandler.php on line 194
I couldnot find the class.
so could you please help me reagarding this issue.
i am very in need of it. (laxman2021@gmail.com)
Lucki - I will respond via e-mail.
ReplyDeleteI have configured the QuickBooks now how actually it shuld be integrated with the existing PHP CMS application the Example index.php and all are working but noiw i have live php files how to integrated our database with QuickBooks Please Let me know as i am facing my deadlines
ReplyDeleteDo i need to install the Web Connector or just use this Framework that will work for me i have just installed the framework for PHP CMS application but then how to keep it in Sync with my database please let me know..
ReplyDeleteHello Keith,
ReplyDeleteI have started to work on quickbook.Following step i have done-
1.Download v3-php-sdk-2.0.5 (1)
2.Download quickbooks-devkit
3.Under build folder(after extract of quickbook).
I create index.php ,other.php.
4.Create a account on developer.intuit.com and update the secreet key token in my files.
Please tell me next step.
Thanks
Please read my comments above -- IF YOU NEED SUPPORT, PLEASE ASK ON OUR FORUMS: http://www.consolibyte.com/forum/
ReplyDeleteI'm sorry, but I can not provide support via this webpage. Ask on the forums instead.
I purchased palmer’s products online from Awesome bazar. Awesome Bazar provides best competitive prices product and fast delivery process . Really very nice service of awesome bazar, Awesome bazaar best Shopping destination. Find At https://awesomebazar.com/brands/palmer-s/
ReplyDeleteCall us Toll Free +1-844-898-4398 For QuickBooks, We Provide Quickbooks Phone Number,Quickbooks Online, Quickbooks Online Login, QuickBooks Login of immediate help 24*7.
ReplyDeleteafter doing the complete configuration when i run the index.php using PHP SDK from github after clicking on connect to quickbook button it gives me the following error
ReplyDeleteOops! An error has occurred.
Please close this window and try again.
Error Code: internal_error
Message: Error getting application from request token
You can contact us for further assistance. Error Id:ixnkryec2iu513ef45f3f5xv-66016491
Your help will be appreciated
Thanks for posting...
ReplyDeletequickbooks intuit number
quickbooks intuit support number
intuit quickbooks number
quickbooks intuit software
quickbooks payroll service
quickbooks payroll service number
quickbooks payroll support number
quickbooks payroll support phone number
quickbooks bookkeeping services
virtual bookkeeping services
remote bookkeeping serivices
Professional bookkeeping serviecs
great post.QuickBooks Integration
ReplyDeletequickbooks helpline number - Are you new user for QuickBooks or facing issues in your quick QuickBooks software? We are a leading QuickBooks tech support provider company in USA. Call us at QuickBooks helpline number 1-855-861-4161 and get solutions for the issues that you are facing.
ReplyDeleteGet speedy reaction from Gemini specialists Are you a Gemini client? Despite numerous capacities, the clients still get into blunders while utilizing Gemini. On the off chance that you ever face nay blunders which are out of your span to comprehend so you can dial Gemini Support Phone Number 1 (800) 861-8259.and search for the most ideal arrangements from the experts. The experts are accessible day and night to help you and put full endeavors in. Gemini Support Phone Number
ReplyDeleteNice Sharing Thanks for the sharing the Superb Information… Quickbooks Integration
ReplyDeleteInformative Article!!!!!!!!!!
ReplyDeletenew integrations
Quickbooks Right Networks Integration
Quickbooks Paypal Integration
Quickbooks Stripe Integration
Quickbooks Integration Walmart
Cs Cart Quickbooks Integration
pinnacle Cart Quickbooks Integration
quickbooks salesforce integration
Quickbooks Online Integration With Etsy
Appguppy: How To Use Keith Palmer'S Php-Devkit To Integrate A Web App With Quickbooks Online >>>>> Download Now
ReplyDelete>>>>> Download Full
Appguppy: How To Use Keith Palmer'S Php-Devkit To Integrate A Web App With Quickbooks Online >>>>> Download LINK
>>>>> Download Now
Appguppy: How To Use Keith Palmer'S Php-Devkit To Integrate A Web App With Quickbooks Online >>>>> Download Full
>>>>> Download LINK Y0