Php Quickbook online service gives 500 internal server

Php Quickbook online service gives 500 internal server,php,curl,quickbooks,quickbooks-online,Php,Curl,Quickbooks,Quickbooks Online,I am trying to call service via curl and here is my code and every time I got the attached error error_reporting(-1); $qbsite = "https://qbo.sbfinance.intuit.com/resource/account/v2/960432556"; $headers = array( 'Content-Type'=>'application/xml', 'oauth_version' => "1.0", 'oauth_signature_method'=>"HMAC-SHA1", 'oauth_nonce'=>"xxx", 'oauth_timestamp'=>"xxx", 'oauth_consumer_key'=>"qyprdvZraQrBVbrPIptwd6gl6C6knP", 'oauth_t

I am trying to call service via curl and here is my code and every time I got the attached error

error_reporting(-1); 
$qbsite = "https://qbo.sbfinance.intuit.com/resource/account/v2/960432556";
$headers = array(
        'Content-Type'=>'application/xml',
        'oauth_version' => "1.0",
        'oauth_signature_method'=>"HMAC-SHA1",
        'oauth_nonce'=>"xxx",
        'oauth_timestamp'=>"xxx",
        'oauth_consumer_key'=>"qyprdvZraQrBVbrPIptwd6gl6C6knP",
        'oauth_token'=>"qyprdyLcCq9KMGVzqxtObeOkTvSWhhi7sNSW62u9gwqDXsc7",
        'oauth_signature'=>"LnVYSgE9YZ77KgKZ1kLT3ouIu1M=",

);

$xmlData = '<?xml version="1.0" encoding="utf-16"?> 
            <Account xmlns:ns2="http://www.intuit.com/sb/cdm/qbo" xmlns="http://www.intuit.com/sb/cdm/v2"> 
                <Name>Loan Account </Name> 
                <Desc>Loan Account</Desc> 
                <Subtype>Savings</Subtype> 
                <AcctNum>5001</AcctNum> 
                <OpeningBalanceDate>2010-05-14</OpeningBalanceDate> 
            </Account>';

$ch = curl_init($qbsite);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, "\n{$xmlData}");
$response = curl_exec($ch);
print($response);die; !

enter image description here


#1

This:

$headers = array(
        'Content-Type'=>'application/xml',
        'oauth_version' => "1.0",
        'oauth_signature_method'=>"HMAC-SHA1",
        'oauth_nonce'=>"xxx",
        'oauth_timestamp'=>"xxx",
        'oauth_consumer_key'=>"qyprdvZraQrBVbrPIptwd6gl6C6knP",
        'oauth_token'=>"qyprdyLcCq9KMGVzqxtObeOkTvSWhhi7sNSW62u9gwqDXsc7",
        'oauth_signature'=>"LnVYSgE9YZ77KgKZ1kLT3ouIu1M=",

);

Is not even close to a correct OAuth signature. OAuth signatures place all of that information in a single Authorization: ... HTTP header, whereas you've slapped each piece of OAuth data in a separate HTTP header.

For example, a correct OAuth header looks something like this:

Authorization: OAuth realm="",
    oauth_consumer_key="dpf43f3p2l4k3l03",
    oauth_nonce="kllo9940pd9333jh",
    oauth_timestamp="1191242096",
    oauth_signature_method="HMAC-SHA1",
    oauth_version="1.0",
    oauth_signature="tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D"

Additionally, OAuth signatures are not static values - they must be calculated and they change with EVERY request.

You should download the nightly build of the QuickBooks PHP DevKit (disclaimer: I'm the author) - it's a library that is specifically designed to do exactly what you're doing (integrate with QuickBooks), and it takes care of building the correct OAuth requests for you.

Specifically, download it and look at these examples:

  • docs/example_ipp_oauth.php
  • docs/example_ipp_ids_5.php

#2

Have you tried removing the , at the end of this line

'oauth_signature'=>"LnVYSgE9YZ77KgKZ1kLT3ouIu1M=",

#3

yes it works but when I am using example_ipp_ids_1.php and added certain data (token,uname and password etc. correctly) $list = $CustomerService->findAll($Context, $realmID); returns emty object while in the QBO I have total 12 customers. any suggestion? or may be because it is nightly build?

#4

docs/example_ipp_ids_1.php is not set up to use OAuth. So unless you swap out all of the initialization stuff at the top of docs/example_ipp_ids_1.php for the OAuth setup stuff, it's not going to work. If you compare the code between the two examples it should be pretty obvious what you need to change.

#5

yes keith I understand that but I just want to fetch all customer list from QBO is there any way to fetch this data....

#6

@RajatModi Yes, there is. You can use similar code to what is shown in docs/example_ipp_ids_1.php, but instead of using $IPP->authenticate(), use $IPP->authMode(QuickBooks_IPP::AUTHMODE_OAUTH, ...) like shown in the other examples I've already mentioned.

#7

yes keith it works like charm thanks mate you are great :) awesome work from you...

#8

yeah but it didn't work :( I am daze with the curl url is it correct? and yes thanks for your quick replay