QuickBooks API“无法打开所需的文件”

时间:2019-08-02 03:13:21

标签: laravel quickbooks-online

我正在将QuickBooks API集成到我新创建的laravel应用中。但是我总是遇到无法打开所需文件的错误。我一直在寻找相同的问题,但没有一个起作用。是否有人尝试将QuickBooks API集成到其laravel应用程序中?你能指导我怎么做吗?

QuickBooks_Loader::load(): Failed opening required 'C:\wamp64\www\...\vendor\consolibyte\quickbooks/QuickBooks\Driver\.php' (include_path='.;C:\php\pear;C:\wamp64\www\...\vendor\consolibyte\quickbooks')

这是设置qbo env变量的方法。

QB_DSN= mysqli://root:@localhost:3306/omni_qbo
QB_TOKEN=AB11573209674XW53cTKF8xf5lY8vva2A4C8aMliPMWgWGUOl7
QB_OAUTH_CONSUMER_KEY= ABsW9nlMQEpjnzYNvl5ySx1FSqpaibMuJEe1DS0xMMt8bKpQoZ
QB_CONSUMER_SECRET=SxbO5CUvclrWWTFTnVCB1ZWvwk8TjqM67shCv3VP

QB_OAUTH_URL=http://localhost:8000/qbo/oauth
QB_SUCCESS_URL=http://localhost:8000/qbo/success

QB_SANDBOX=true

QB_USERNAME=DO_NOT_CHANGE_ME
QB_TENANT=12345

这是我从link复制的控制器示例代码。我只是按照有关如何将quickbooks api集成到laravel的步骤进行操作,但仍然无法正常工作。

<?php

namespace App\Http\Controllers;
use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class QuickBookController extends Controller
{

    private $IntuitAnywhere;
    private $context;
    private $realm;

    public function __construct(){
        if (!\QuickBooks_Utilities::initialized(env('QBO_DSN'))) {
            // Initialize creates the neccessary database schema for queueing up requests and logging
            \QuickBooks_Utilities::initialize(env('QBO_DSN'));
        }
        $this->IntuitAnywhere = new \QuickBooks_IPP_IntuitAnywhere(env('QBO_DSN'), env('QBO_ENCRYPTION_KEY'), env('QBO_OAUTH_CONSUMER_KEY'), env('QBO_CONSUMER_SECRET'), env('QBO_OAUTH_URL'), env('QBO_SUCCESS_URL'));
    }
    public function  qboConnect(){


        if ($this->IntuitAnywhere->check(env('QBO_USERNAME'), env('QBO_TENANT')) && $this->IntuitAnywhere->test(env('QBO_USERNAME'), env('QBO_TENANT'))) {
            // Set up the IPP instance
            $IPP = new \QuickBooks_IPP(env('QBO_DSN'));
            // Get our OAuth credentials from the database
            $creds = $this->IntuitAnywhere->load(env('QBO_USERNAME'), env('QBO_TENANT'));
            // Tell the framework to load some data from the OAuth store
            $IPP->authMode(
                \QuickBooks_IPP::AUTHMODE_OAUTH,
                env('QBO_USERNAME'),
                $creds);

            if (env('QBO_SANDBOX')) {
                // Turn on sandbox mode/URLs
                $IPP->sandbox(true);
            }
            // This is our current realm
            $this->realm = $creds['qb_realm'];
            // Load the OAuth information from the database
            $this->context = $IPP->context();

            return true;
        } else {
            return false;
        }
    }

    public function qboOauth(){
        if ($this->IntuitAnywhere->handle(env('QBO_USERNAME'), env('QBO_TENANT')))
        {
            ; // The user has been connected, and will be redirected to QBO_SUCCESS_URL automatically.
        }
        else
        {
            // If this happens, something went wrong with the OAuth handshake
            die('Oh no, something bad happened: ' . $this->IntuitAnywhere->errorNumber() . ': ' . $this->IntuitAnywhere->errorMessage());
        }
    }

    public function qboSuccess(){
        return view('qbo_success');
    }

    public function qboDisconnect(){
        $this->IntuitAnywhere->disconnect(env('QBO_USERNAME'), env('QBO_TENANT'),true);
        return redirect()->intended("/yourpath");// afer disconnect redirect where you want

    }

0 个答案:

没有答案