3

Hello guys I'm new to quickbooks. There is some data in quickbooks which I'm trying to retrieve but quickbooks is returning nothing. I can figure out what is it that I'm doing wrong. I'm trying to retrieve data like this

QUICKBOOKS. PHP

$serviceType = IntuitServicesType::QBO;
$realmId = $this->CI->session->userdata('realmId');
$token = unserialize($this->CI->session->userdata('token'));
$requestValidator = new OAuthRequestValidator($token["oauth_token"],
                    $token["oauth_token_secret"],
                    $this->CI->config->item('OAUTH_CONSUMER_KEY'),
                    $this->CI->config->item('OAUTH_CONSUMER_SECRET'));
$serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator);
$dataService = new DataService($serviceContext);
$entities = $dataService->Query("SELECT * FROM SalesReceipt");
error_log(print_r($entities , true));

can somebody tell me what is it that I'm doing wrong. Thanks

Gardezi
  • 2,692
  • 2
  • 32
  • 62

1 Answers1

0

The first thing you should do in a case like this, is turn on logging, and post the logs.

There is not much anyone can tell you here without seeing your logs.

With that said, it's worth nothing that this error:

instead of dataservice I tried using QuickBooks_IPP_Services_SalesReceipt but it's giving me a error salesrecipt class is not defined

Is because that class is from a totally separate, unrelated PHP code library. If you want to use that class, then what you should do is:

.

$SalesReceiptService = new QuickBooks_IPP_Service_SalesReceipt();
$salesreceipts = $SalesReceiptService->query($Context, $realm, "SELECT * FROM SalesReceipt STARTPOSITION 1 MAXRESULTS 10");

foreach ($salesreceipts as $SalesReceipt)
{
    print('Receipt # ' . $SalesReceipt->getDocNumber() . ' has a total of $' . $SalesReceipt->getTotalAmt() . "\n");

}

If you still have trouble, you can get the HTTP request/response like this:

print($IPP->lastError($Context));
print("\n\n\n\n");
print('Request [' . $IPP->lastRequest() . ']');
print("\n\n\n\n");
print('Response [' . $IPP->lastResponse() . ']');

More examples can be found here:

Keith Palmer Jr.
  • 27,666
  • 16
  • 68
  • 105