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 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误