2013-03-19 41 views
1

我嘗試添加發票使用基思·帕默PHP API添加發票QuickBooks的在線使用PHP API(基思·帕默)

時能夠增加客戶名單發票通過我的應用程序的QuickBook和做一堆東西的從它..

但是當我嘗試使用它沒有獲得創建基本的諸如添加發票..

繼承人我的代碼片段

<?php 

     $Invoice = new QuickBooks_IPP_Object_Invoice(); 
     $Header = new QuickBooks_IPP_Object_Header(); 


     $Header->setTxnDate('2013-03-20'); 
     $Header->setCustomerId('{QBO-2}'); 

     $Header->setTotalAmt(101); 

     $Invoice->addHeader($Header); 

     $Line = new QuickBooks_IPP_Object_Line(); 
     $Line->setDesc('Invoice desp comes here'); 
     $Line->setTaxable('false'); 
     $Line->setItemId('{QBO-2}'); 
     $Line->setAmount(101); 

     $Invoice->addLine($Line); 

     print_r($Invoice->asIDSXML()); 

     print_r('Request [' . $IPP->lastRequest() . ']'); 
     print_r("<br/><br/>"); 
     print_r('Response [' . $IPP->lastResponse() . ']'); 
     print_r("<br/><br/>"); 

?> 

的print_r($在語音 - > asIDSXML())告訴我這個

<Invoice> 
    <Header> 
     <TxnDate>2013-03-20</TxnDate> 
     <CustomerId idDomain="QBO">2</CustomerId> 
     <TotalAmt>101.00</TotalAmt> 
    </Header> 
    <Line> 
     <Desc>test input invoice descp comes here</Desc> 
     <Amount>101</Amount> 
     <Taxable>false</Taxable> 
     <ItemId idDomain="QBO">2</ItemId> 
    </Line> 
</Invoice> 

print_r('Request ['。 $ IPP-> lastRequest()。 ']')表明我這個

Request [GET https://qbo.intuit.com/qbo1/rest/user/v2/666328865?oauth_consumer_key=qyprdorhgMjAeQswpCnBBuFUt5NGlv&oauth_nonce=GCRwB&oauth_signature=FKjWjA8VSwtxKvn%2ByGb1LaYd7Kw%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1363757537&oauth_token=qyprdmoCHU437qAutsaqwMzki7izqqjl7cioaZO4uTxkykse&oauth_version=1.0 HTTP/1.1 
Content-Type: application/x-www-form-urlencoded 
Content-Length: 0 

] 

的print_r( '響應['。$ IPP-> lastResponse()。 ']')表明我這個

Response [HTTP/1.1 200 OK 
Date: Wed, 20 Mar 2013 05:32:17 GMT 
Server: Apache 
Set-Cookie: qboeuid=10.129.32.5.1363757537351379; path=/; expires=Thu, 20-Mar-14 05:32:17 GMT; domain=.intuit.com 
Cache-Control: private 
Expires: Wed, 31 Dec 1969 16:00:00 PST 
Set-Cookie: JSESSIONID=3BC45AC1AAA82F57D777FF1DAB2F9729.c1-pprdqboas30d; Path=/; Secure; HttpOnly 
Content-Encoding: gzip 
Content-Length: 290 
Content-Type: application/xml;charset=UTF-8 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><qbo:QboUser xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:qbp="http://www.intuit.com/sb/cdm/qbopayroll/v1" xmlns:qbo="http://www.intuit.com/sb/cdm/qbo"><qbo:LoginName>[email protected]</qbo:LoginName><qbo:Ticket>V1-48-Q0czg6etf4a8rhn9mxnc5a</qbo:Ticket><qbo:AgentId>666328880</qbo:AgentId><qbo:CurrentCompany><qbo:CompanyId>666328865</qbo:CompanyId><qbo:BaseURI>https://sg.qbo.intuit.com/qbo37</qbo:BaseURI></qbo:CurrentCompany></qbo:QboUser>] 
+0

您需要發佈由所有這些產生的實際XML。您正在瀏覽器中查看它,並且瀏覽器隱藏了XML標籤。查看源代碼併發布實際的XML。 – 2013-03-19 11:38:37

+0

@凱斯帕爾默:我這樣做了,我放了 $ InvoiceService = new QuickBooks_IPP_Service_Invoice();在頂部 和底部之後 $ Invoice-> addLine($ Line);我放置 $ resp = $ InvoiceService-> add($ Context,$ realmID,$ Invoice); 這是正確的方法....我不知道如何發佈它.... – 2013-03-19 11:50:53

+0

***在您的瀏覽器中查看源***併發布實際的XML。您發佈的所有內容都不是完整的XML。這與CODE無關,這與你不復制/粘貼實際的XML有關 - 你只是複製/粘貼*瀏覽器呈現的*。 – 2013-03-19 12:10:35

回答

3

我的問題是,我沒有添加相應的服務對象爲此有效,下面給出的代碼片段現在可以很好地工作了......

<?php 

    $InvoiceService = new QuickBooks_IPP_Service_Invoice(); 
    $Invoice = new QuickBooks_IPP_Object_Invoice(); 
    $Header = new QuickBooks_IPP_Object_Header(); 


    $Header->setTxnDate('2013-03-20'); 
    $Header->setCustomerId('{QBO-2}'); 
    $Header->setTotalAmt(101); 

    $Invoice->addHeader($Header); 

    $Line = new QuickBooks_IPP_Object_Line(); 
    $Line->setDesc('Invoice desp comes here'); 
    $Line->setTaxable('false'); 
    $Line->setItemId('{QBO-2}'); 
    $Line->setAmount(101); 

    $Invoice->addLine($Line); 

    print_r($Invoice->asIDSXML()); 

    $resp = $InvoiceService->add($Context, $realmID, $Invoice); 

    pr('New invoice is [' . $resp . ']' . "\n"); 

    print_r('Request [' . $IPP->lastRequest() . ']'); 
    print_r("<br/><br/>"); 
    print_r('Response [' . $IPP->lastResponse() . ']'); 
    print_r("<br/><br/>"); 

?> 
相關問題