【问题标题】:QuickBooks PHP API - Can't get through the oAuth process againQuickBooks PHP API - 无法再次通过 oAuth 流程
【发布时间】:2017-05-09 23:56:18
【问题描述】:

首先:我正在使用https://github.com/consolibyte/quickbooks-php

我不小心断开了应用程序与“应用程序”页面的连接以尝试重新连接(获取新的身份验证凭据),但似乎这是一个错误。

所以现在我正在尝试再次完成授权过程,但是当我单击“docs/example_app_ipp_v3/”页面上的“连接到 QuickBooks”按钮时出现错误,如快速入门指南中所述.

这里有什么我遗漏的吗?我仍然可以通过 API 资源管理器进行查询,但是当我在代码中使用 $InvoiceService->query 时似乎无法取回任何数据(只是返回 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
        }
    }
}

我从 var_dump($invoice_query) 得到 bool(false),即使它通过了 if($Context = $IPP->context())

然后,当我访问“docs/example_app_ipp_v3/”页面时,除了将配置更新为我当前的身份验证凭据之外什么都没有,“连接到 Quickbooks”按钮(下面的 html)会将我带到 404 页面。

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

【问题讨论】:

  • 但是您没有发布任何代码,所以我们无法帮助您。发布您的代码。
  • @KeithPalmerJr。抱歉,已更新。

标签: php api quickbooks


【解决方案1】:

您确定您的应用程序令牌和其他凭据在 config.php 文件中是正确的吗?如果它们是沙盒/开发令牌,请发布配置文件。

您确定配置文件中的 URL 是正确的吗?如果它们是沙盒/开发者,请发布它们。

$sandbox 设置为 TRUE 还是 FALSE?这是否与您使用的令牌相对应?

【讨论】:

  • 我确信凭据是正确的。但可以肯定的是,我刚刚下载了最新的文件,从github.com/consolibyte/quickbooks-php 上传了整个 quickbooks-php 包。我假设在尝试连接时将默认数据保留在那里会产生某种结果,但是一旦我单击“连接到 Quickbooks”按钮,它就会挂起对quickbooks.v3.com:8888/quickbooks-php/docs/partner_platform/… 的请求。它只是在连接屏幕应该在的位置显示一个空白弹出窗口。我也登录了我的 QuickBooks 帐户。
  • 我将凭据设置为我的生产密钥,关闭了沙箱,并将身份验证 URL 设置为当前目录,并且成功了!我在原始版本中没有 $sandbox url,所以这让我感到困惑。感谢您耐心指导我正确实施!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-03-17
  • 2013-07-10
  • 1970-01-01
相关资源
最近更新 更多