Search code examples
phpapiquickbooks

QuickBooks PHP API - Can't get through the oAuth process again


First off: I'm using https://github.com/consolibyte/quickbooks-php

I accidentally disconnected the APP from the "Apps" page in an attempt to reconnect (get new auth creds), but it appears that was a mistake.

So now I'm trying to go through the authorization process again but I'm getting an error when I click the "Connect to QuickBooks" button on the "docs/example_app_ipp_v3/" page as described in the Quick-Start guide.

Is there something I'm missing here? I can still query through the API explorer, but I can't seem to get any data back when I use $InvoiceService->query in the code (just returns false).

//get invoice info
require_once '../includes/quickbooks-php/config.php';

// Set up the IPP instance
$IPP = new QuickBooks_IPP($dsn);

// Get our OAuth credentials from the database
$creds = $IntuitAnywhere->load($the_username, $the_tenant);

//error_reporting(0);
//ini_set('display_errors', 1);

// Tell the framework to load some data from the OAuth store
$IPP->authMode(
    QuickBooks_IPP::AUTHMODE_OAUTH, 
    $the_username, 
    $creds);

// This is our current realm
$realm = $creds['qb_realm'];

// Load the OAuth information from the database
if ($Context = $IPP->context())
{

    // Set the IPP version to v3 
    $IPP->version(QuickBooks_IPP_IDS::VERSION_3);

    $CustomerService = new QuickBooks_IPP_Service_Customer();
    $InvoiceService = new QuickBooks_IPP_Service_Invoice();
    $ItemService = new QuickBooks_IPP_Service_Item();
    $PaymentService = new QuickBooks_IPP_Service_Payment();

    $invoice_query = $InvoiceService->query($Context, $realm, "SELECT *, Line.* FROM Invoice WHERE Id = '" .QuickBooks_IPP_IDS::usableIDType($main_invoice['qb_invoice_id']). "'");
    $this_invoice = array();

    var_dump($invoice_query);

    if (count($invoice_query)){

        foreach ($invoice_query as $Invoice){
            //do stuff with invoice here
        }
    }
}

I'm getting bool(false) from the var_dump($invoice_query) even though it gets through the if($Context = $IPP->context())

Then when I visit the "docs/example_app_ipp_v3/" page with nothing but the config updated to my current auth credentials the "Connect to Quickbooks" button (html below) takes me to the 404 page.

<ipp:connecttointuit><a href="javascript:void(0)" class="intuitPlatformConnectButton">Connect with QuickBooks</a></ipp:connecttointuit>

enter image description hereenter image description here


Solution

  • Are you POSITIVE that your App Token and other credentials are correct in the config.php file? If they are sandbox/dev tokens, please post the config file.

    Are you POSITIVE that the URLs in your configuration file are correct? If they are sandbox/dev, please post them.

    Is $sandbox set to TRUE or FALSE? Does that correspond to the tokens you're using?