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 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计