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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?