<?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"
]
]);
?>
致命错误:未捕捉错误:班级&#39;线路&#39;在/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致命错误:未捕获错误:类&#39; IPPPurchaseOrderItemLineDetail&#39;在/var/www/html/QuickBooks-V3-PHP-SDK-master/purchaseOrder.php:20中找不到
为什么我会收到这些错误?自动加载不起作用?我应该直接包含我需要的类文件吗?
答案 0 :(得分:0)
关于下面的第一个错误:
致命错误:未捕获错误:/var/www/html/QuickBooks-V3-PHP-SDK-master/Test2.php:24中找不到类'行'
我没有看到你在任何地方都包含Line
类,来自GitHub页面here我已经截断了他们的建议:
连接到QuickBooks Online API
目前,以下API实体Endpoints支持从Array创建对象:
对于创建/更新上面的实体端点,您将导入相应的Facade类:
use QuickBooksOnline\API\Facades\{Facade_Class_Name};
因此,您需要更新您的第一个脚本以包含此Facade,它应该如下所示:
<?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
关于以下第二个错误:
PHP致命错误:未捕获错误:在/var/www/html/QuickBooks-V3-PHP-SDK-master/purchaseOrder.php:20中找不到类'IPPPurchaseOrderItemLineDetail'
从再次搜索GitHub代码库,我可以看到这个类被声明为here。因此,它应该像在使用此文件的文件顶部的use
语句中再次声明这一样简单,如下所示:
<?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
查看代码的其余部分,似乎有很多类没有通过use
,PurchaseOrder
和IPPLine
等IPPPurchaseOrder
语句声明这些类。你还需要包括。