Quickbooks Php SDK - CheckNullResponseAndThrowException - 响应空或空

Please kindly assist me on below error: 2015-04-16 10:45:10 - D:\projects\QuickBooksv3-php-sdk-2.0.5\DataService\DataService.php - 340 - CheckNullResponseAndThrowException - Response Null or Empty

3 days ago, I had successfully test quickbooks php sdk. But today when I going to integrate with system, it hit error. The code is same as 3 days ago.

Here is my code:

//Create new invoice
$invoiceObj2 = new IPPInvoice();
$invoiceObj2->DocNumber="1025";

//Add customer
$customerRef2= new IPPReferenceType();
$customerRef2->value= "1";
$invoiceObj2->CustomerRef= $customerRef2;

//Create Line
$line2 = new IPPLine();
$line2->Amount= 1*90.84;

$linetype2= new IPPLineDetailTypeEnum();
$linetype2->value="SalesItemLineDetail";

$lineDetail2 = new IPPSalesItemLineDetail();
$lineDetail2->ItemRef = "4";
$lineDetail2->UnitPrice = 90.84;
$lineDetail2->Qty= 1;

$line2->DetailType=$linetype2;
$line2->SalesItemLineDetail=$lineDetail2;

$invoiceObj2->Line=$line2;

$resultingInvoiceObj2 = $dataService->Add($invoiceObj2);

echo "Created Invoice Id={$resultingInvoiceObj2->Id}. Reconstructed response body:<br/><br/>";
$xmlBody = XmlObjectSerializer::getPostXmlFromArbitraryEntity($resultingInvoiceObj2, $urlResource);
echo "<pre>";
echo $xmlBody . "<br/>";
echo "</pre>";

Please kindly help to point out my mistake. Thanks

Please change the base url for using sandbox QBO account or use production tokens for connecting to existing QBO accounts. Your issue might be related to this change-https://developer.intuit.com/v2/blog/2014/10/24/intuit-developer-now-offers-quickbooks-sandboxes

You can also try changing the values and then try integrating into QB

I have solved same problem checking required params. Please check required fields.

Required fields are at least:

DocNumber
TxnDate
CustomerRef

at least one Line record

Line.DetailType
Line.Amount
Line.Description

at least one Line.SalesItemLineDetail

Line.SalesItemLineDetail.ItemRef
Line.SalesItemLineDetail.Quantity
Line.SalesItemLineDetail.UnitPrice

I have modified your code and run. Its working

Final modified code:

//Create new invoice
$invoiceObj2 = new IPPInvoice();
$invoiceObj2->DocNumber="1025";
$invoiceObj2->TxnDate = "2016-10-19";

//Add customer
$customerRef2= new IPPReferenceType();
$customerRef2->value= "1";
$invoiceObj2->CustomerRef= $customerRef2;

//Create Line
$line2 = new IPPLine();
$line2->Amount= 1*90.84;
$Line2->Description = 'Test Product';

$linetype2= new IPPLineDetailTypeEnum();
$linetype2->value="SalesItemLineDetail";

$lineDetail2 = new IPPSalesItemLineDetail();
$lineDetail2->ItemRef = "4";
$lineDetail2->UnitPrice = 90.84;
$lineDetail2->Qty= 1;

$line2->DetailType=$linetype2;
$line2->SalesItemLineDetail=$lineDetail2;

$invoiceObj2->Line=$line2;

$resultingInvoiceObj2 = $dataService->Add($invoiceObj2);

echo "Created Invoice Id={$resultingInvoiceObj2->Id}. Reconstructed response body:<br/><br/>";
$xmlBody = XmlObjectSerializer::getPostXmlFromArbitraryEntity($resultingInvoiceObj2, $urlResource);
echo "<pre>";
echo $xmlBody . "<br/>";
echo "</pre>";