第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

使用 php Xero api 在 Xero 中添加附件

使用 php Xero api 在 Xero 中添加附件

PHP
犯罪嫌疑人X 2023-04-28 14:24:05
誰(shuí)能幫助我使用官方(非 calcanai)PHP SDK 將 pdf 添加到 Xero 發(fā)票。我與 oAuth2 相關(guān)聯(lián)并且之前創(chuàng)建了草稿發(fā)票。然后我將發(fā)票更新為 Authorized 并嘗試向發(fā)票添加附件。在這一點(diǎn)上我沒(méi)有任何運(yùn)氣,附件已發(fā)送但返回時(shí)為空。這些文檔一點(diǎn)用處都沒(méi)有,也沒(méi)有給出任何添加附件甚至最小字段的示例。所以這就是我所擁有的:...        $attachments = $apiResponse->getInvoices()[0]->getAttachments();        $attachment = new XeroAPI\XeroPHP\Models\Accounting\Attachment;        $attachment->setFileName( $filename )            ->setIncludeOnline( true )            ->setMimeType( 'application/pdf' );        $attachments[] = $attachment;        $apiResponse->getInvoices()[0]->setAttachments( $attachments );        $apiResult = $accountingApi->updateOrCreateInvoices( $xeroTenantId, $apiAuth );            if ( !$apiResult->getInvoices()[0]->getHasAttachments() ) {                $errors[] = 'Pdf file was not added to Xero.';            }            $errorList = array();            $errList = $apiResult->getInvoices()[0]->getValidationErrors()[0];            if ( !is_null( $errList ) ) {                $errorList = $errList;            }            foreach ( $errorList as $err ) {                $errors[] = $err->getMessage();            }            if ( count( $errors ) == 0 ) {                $result['message'] = 'New Invoice Authorised: ' . $xeroInvoice->getReference();                $result['apiResult'] = $apiResult;                $result['success'] = true;            } else {                $result['message'] = print_r( $errors );                $result['success'] = false;            }...有任何想法嗎?
查看完整描述

1 回答

?
慕姐8265434

TA貢獻(xiàn)1813條經(jīng)驗(yàn) 獲得超2個(gè)贊

添加附件需要兩次 API 調(diào)用。


// 創(chuàng)建或獲取您的發(fā)票 ID,然后創(chuàng)建附件


    $invoices = $apiInstance->getInvoices($xeroTenantId);                       

    $guid = $invoices->getInvoices()[0]->getInvoiceId();


    // file in the same dir.        

    $filename = "./helo-heros.jpg";

    $handle = fopen($filename, "r");

    $contents = fread($handle, filesize($filename));

    fclose($handle);


    $result = $apiInstance->createInvoiceAttachmentByFileName($xeroTenantId,$guid,"helo-heros.jpg",$contents);



查看完整回答
反對(duì) 回復(fù) 2023-04-28
  • 1 回答
  • 0 關(guān)注
  • 150 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)