douduan4116 2017-07-20 17:33
浏览 44
已采纳

quickbooks php sdk类未找到

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

require "vendor/autoload.php";
use QuickBooksOnline\API\DataService\DataService;
use QuickBooksOnline\API\Facades\Invoice;
use QuickBooksOnline\API\Facades\PurchaseOrder;



$dataService = DataService::Configure(array(
         'auth_mode' => 'oauth1',
         'consumerKey' => " ", 
         'consumerSecret' => " ",
         'accessTokenKey' => " ",
         'accessTokenSecret' => " ",
         'QBORealmID' => "",
         'baseUrl' => "https://quickbooks.api.intuit.com/"
));

for($i = 1; $i<= 3; $i ++){
   $LineObj = Line::create([
       "Id" => $i,
       "LineNum" => $i,
       "Description" => "Pest Control Services",
       "Amount" => 35.0,
       "DetailType" => "SalesItemLineDetail",
       "SalesItemLineDetail" => [
           "ItemRef" => [
               "value" => "1",
               "name" => "Pest Control"
           ],
           "UnitPrice" => 35,
           "Qty" => 1,
           "TaxCodeRef" => [
               "value" => "NON"
           ]
       ]
   ]);
   $lineArray[] = $LineObj;
}
//Add a new Invoice
$theResourceObj = PurchaseOrder::create([
     "Line" =>  $lineArray,
    "CustomerRef"=> [
     "value"=> "1"
     ],
      "BillEmail" => [
            "Address" => "Familiystore@intuit.com"
      ],
      "BillEmailCc" => [
            "Address" => "a@intuit.com"
      ],
      "BillEmailBcc" => [
            "Address" => "v@intuit.com"
      ]
]);
?>

Fatal error: Uncaught Error: Class 'Line' not found in /var/www/html/QuickBooks-V3-PHP-SDK-master/Test2.php:24

purchaseOrder.php:

<?php

//require "vendor/autoload.php";
include('src/config.php');

use QuickBooksOnline\API\DataService\DataService;
use QuickBooksOnline\API\Facades\Invoice;
use QuickBooksOnline\API\Facades\PurchaseOrder;

// OBOT Data service
$dataService = DataService::Configure(array(
       'auth_mode' => 'oauth1',
         'consumerKey' => " ",
         'consumerSecret' => " ",
         'accessTokenKey' => " ",
         'accessTokenSecret' => " ",
         'QBORealmID' => " ",
         'baseUrl' => "https://quickbooks.api.intuit.com/" 
));

$linedet = new IPPPurchaseOrderItemLineDetail();
$linedet->CustomerRef  = 86;

$line = new IPPLine();
$line->Id = 0;
$line->Description = 'test purchase order';
$line->Amount = 2.00;
$line->DetailType= 'ItemBasedExpenseLineDetail ';
$line->ItemBasedExpenseLineDetail = $linedet;
$line->BillableStatus = 'Notbillable';
$line->ItemRef = '19';
$line->UnitPrice = '25';
$line->Qty = '1';

$purchaseOrder = new IPPPurchaseOrder();
$purchaseOrder->Line = $line;
$purchaseOrder->VendorRef = 85;
$purchaseOrder->APAccountRef = 1;
$purchaseOrder->TotalAmt = 200.00;
$result = $dataService->Add($purchaseOrder); //add purchase order

?>

PHP Fatal error: Uncaught Error: Class 'IPPPurchaseOrderItemLineDetail' not found in /var/www/html/QuickBooks-V3-PHP-SDK-master/purchaseOrder.php:20

Why am I getting these errors? is the autoload not working? should I just directly include the class files that I need?

  • 写回答

1条回答 默认 最新

  • duanchan5458 2017-07-24 18:28
    关注

    In regards your first error below:

    Fatal error: Uncaught Error: Class 'Line' not found in /var/www/html/QuickBooks-V3-PHP-SDK-master/Test2.php:24

    I don't see you including the Line class anywhere, from the GitHub page here I have truncated their advice:

    Connecting to the QuickBooks Online API

    Currently the below API entity Endpoints support creating Objects from Array:

    • Estimate
    • Line
    • Invoice
    • Item

    For create/update above entity endpoints, you are going to import corresponding facade class:

    use QuickBooksOnline\API\Facades\{Facade_Class_Name};
    

    As such you need to update your first script to include this Facade, which should be as simple as:

    <?php
    
    require "vendor/autoload.php";
    
    use QuickBooksOnline\API\DataService\DataService;
    use QuickBooksOnline\API\Facades\Invoice;
    use QuickBooksOnline\API\Facades\PurchaseOrder;
    use QuickBooksOnline\API\Facades\Line; // <-- You are missing this line
    

    In regards the second error below:

    PHP Fatal error: Uncaught Error: Class 'IPPPurchaseOrderItemLineDetail' not found in /var/www/html/QuickBooks-V3-PHP-SDK-master/purchaseOrder.php:20

    From searching the GitHub codebase again I can see this class is declared here. Therefore it should be as simple as declaring this again in your use statements at the top of the file that is using this, such as below:

    <?php
    
    //require "vendor/autoload.php";
    include('src/config.php');
    
    use QuickBooksOnline\API\DataService\DataService;
    use QuickBooksOnline\API\Facades\Invoice;
    use QuickBooksOnline\API\Facades\PurchaseOrder;
    use QuickBooksOnline\API\Data\IPPPurchaseOrderItemLineDetail; // <-- You are missing this line
    

    Looking at the rest of your code there seems to be a lot of classes that you are not declaring through use statements such as PurchaseOrder, IPPLine and IPPPurchaseOrder which you will also need to include.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 安装opengauss数据库报错
  • ¥15 【急】在线问答CNC雕刻机的电子电路与编程
  • ¥60 在mc68335芯片上移植ucos ii 的成功工程文件
  • ¥15 笔记本外接显示器正常,但是笔记本屏幕黑屏
  • ¥15 Python pandas
  • ¥15 蓝牙硬件,可以用哪几种方法控制手机点击和滑动
  • ¥15 生物医学数据分析。基础课程就v经常唱课程舅成牛逼
  • ¥15 云环境云开发云函数对接微信商户中的分账功能
  • ¥15 空间转录组CRAD遇到问题
  • ¥20 materialstudio计算氢键脚本问题