0

我正在使用 Consolibyte PHP Quickbooks 连接。连接到 quickbooks 后出现错误:

获取用户令牌时出错了

如果我再试一次,我会收到错误:

IntuitAnywhere.php 第 468 行中的 ErrorException:未定义索引:oauth_token

我已经使用它快一年了,没有任何问题。昨天我们无法从 api 接收付款数据。我尝试断开连接并重新连接,这开始发生。我不知道该怎么办。我们有 mcrypt 设置,我们正在使用 php 7。我还更新到最新版本的 github repo,看看是否可以修复它,但它仍然在做同样的事情。

谢谢您的帮助!

这是我的配置文件

          error_reporting(E_ALL);
        ini_set('display_errors', 1);


// Your application token (Intuit will give you this when you register an Intuit Anywhere app)
        $token = env('TOKEN');

// Your OAuth consumer key and secret (Intuit will give you both of these when you register an Intuit app)
//
// IMPORTANT:
//  To pass your tech review with Intuit, you'll have to AES encrypt these and
//  store them somewhere safe.
//
// The OAuth request/access tokens will be encrypted and stored for you by the
//  PHP DevKit IntuitAnywhere classes automatically.
        $oauth_consumer_key = env('KEY');
        $oauth_consumer_secret = env('SECRET');

// If you're using DEVELOPMENT TOKENS, you MUST USE SANDBOX MODE!!!  If you're in PRODUCTION, then DO NOT use sandbox.
        $sandbox = env('SANDBOX');     // When you're using development tokens
      //  $sandbox = true;    // When you're using production tokens

// This is the URL of your OAuth auth handler page
        $quickbooks_oauth_url = env('OAUTH');

// This is the URL to forward the user to after they have connected to IPP/IDS via OAuth
        $quickbooks_success_url = env('SUCCESS');

// This is the menu URL script
        $quickbooks_menu_url = env('MENU');

// This is a database connection string that will be used to store the OAuth credentials
// $dsn = 'pgsql://username:password@hostname/database';
// $dsn = 'mysql://username:password@hostname/database';
        $dsn = 'mysqli://'.env('DB_USER').':'.env('DB_PASS').'@'. env('DB_HOST').'/'.env('DB');

// You should set this to an encryption key specific to your app
        $encryption_key = env('ENCRYPT');

// Do not change this unless you really know what you're doing!!!  99% of apps will not require a change to this.
        $the_username = 'DO_NOT_CHANGE_ME';

// The tenant that user is accessing within your own app
        $the_tenant = 12345;

// Initialize the database tables for storing OAuth information
        if (!\QuickBooks_Utilities::initialized($dsn)) {
        // Initialize creates the neccessary database schema for queueing up requests and logging
            \QuickBooks_Utilities::initialize($dsn);
        }

// Instantiate our Intuit Anywhere auth handler
//
// The parameters passed to the constructor are:
//  $dsn
//  $oauth_consumer_key     Intuit will give this to you when you create a new Intuit Anywhere application at AppCenter.Intuit.com
//  $oauth_consumer_secret  Intuit will give this to you too
//  $this_url               This is the full URL (e.g. http://path/to/this/file.php) of THIS SCRIPT
//  $that_url               After the user authenticates, they will be forwarded to this URL
//
        $IntuitAnywhere = new \QuickBooks_IPP_IntuitAnywhere($dsn, $encryption_key, $oauth_consumer_key, $oauth_consumer_secret, $quickbooks_oauth_url, $quickbooks_success_url);

// Are they connected to QuickBooks right now?
        if ($IntuitAnywhere->check($the_username, $the_tenant) and
            $IntuitAnywhere->test($the_username, $the_tenant)
        ) {
        // Yes, they are
            $quickbooks_is_connected = true;

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

            // 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
            );

            if ($sandbox) {
            // Turn on sandbox mode/URLs
                $IPP->sandbox(true);
            }

            // 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
            $Context = $IPP->context();

            // Get some company info
            $CompanyInfoService = new \QuickBooks_IPP_Service_CompanyInfo();
            $quickbooks_CompanyInfo = $CompanyInfoService->get($Context, $realm);

            return [$realm, $Context];
        } else {
            // No, they are not
            $quickbooks_is_connected = false;

            return [$realm, $Context];
        }
    }

这是我的连接文件。这是一个刀片模板,因此脚本包含在我的页脚中:

    @extends('app')

@section('content')


    <?php if ($quickbooks_is_connected): ?>
    <ipp:blueDot></ipp:blueDot>
    <?php endif; ?>

    <div>
    <p>
        QuickBooks connection status:

    <?php if ($quickbooks_is_connected): ?>
    <div style="border: 2px solid green; text-align: center; padding: 8px; color: green;">
        CONNECTED!<br>
        <br>

    </div>

    <table>
        <tr>
            <td>
                <a href="disconnect">Disconnect from QuickBooks</a>
            </td>
            <td>
                (If you do this, you'll have to go back through the authorization/connection process to get connected again)
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>
                <a href="reconnect">Reconnect / refresh connection</a>
            </td>
            <td>
                (QuickBooks connections expire after 6 months, so you have to this roughly every 5 and 1/2 months)
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>
                <a href="diagnostics">Diagnostics about QuickBooks connection</a>
            </td>
            <td>
                &nbsp;
            </td>
        </tr>
    </table>

    <?php else: ?>
    <div style="border: 2px solid red; text-align: center; padding: 8px; color: red;">
        <b>NOT</b> CONNECTED!<br>
        <br>
        <ipp:connectToIntuit></ipp:connectToIntuit>
        <br>
        <br>
        You must authenticate to QuickBooks <b>once</b> before you can exchange data with it. <br>
        <br>
        <strong>You only have to do this once!</strong> <br><br>

        After you've authenticated once, you never have to go
        through this connection process again. <br>
        Click the button above to
        authenticate and connect.
    </div>
    <?php endif; ?>

    </p>
</div>
@endsection
@section('scripts')
    <script type="text/javascript" src="https://appcenter.intuit.com/Content/IA/intuit.ipp.anywhere.js"></script>
    <script type="text/javascript">
        intuit.ipp.anywhere.setup({
            menuProxy: '<?php print($quickbooks_menu_url); ?>',
            grantUrl: '<?php print($quickbooks_oauth_url); ?>'
        });
    </script>
@endsection

如果我没有正确发布,我很抱歉,我之前没有在这里问过任何问题。

我运行了 Keith 提到的故障排除脚本,输出如下:

> Trying to hit URL: oauth.intuit.com/oauth/v1/get_request_token Did we disable SSL checks? false * Hostname was NOT found in DNS cache * Could not resolve host: oauth.intuit.com * Closing connection 67 

Trying to hit URL: appcenter.intuit.com/api/v1/Connection/Reconnect Did we disable SSL checks? false * Hostname was NOT found in DNS cache * Could not resolve host: appcenter.intuit.com * Closing connection 68 

Trying to hit URL: oauth.intuit.com/oauth/v1/get_request_token Did we disable SSL checks? true * Hostname was NOT found in DNS cache * Could not resolve host: oauth.intuit.com * Closing connection 69 

Trying to hit URL: appcenter.intuit.com/api/v1/Connection/Reconnect Did we disable SSL checks? true * Hostname was NOT found in DNS cache * Could not resolve host: appcenter.intuit.com * Closing connection 70 

php version: 7.0.1-4+deb.sury.org~trusty+1 mcrypt extension? true mcrypt module rijndael-256? NULL curl extension? true 
4

0 回答 0