0

ここからphpライブラリを使用していますが、小さな問題があります。

請求書 118868 の情報を取得するには、次のようにします。

<?php
$invoice_id=118868;

$invoice=$freshbooks->invoiceGet($invoice_id);
print_r($invoice);
?>

これは print_r の出力です

Class Object ( [@attributes] => stdClass Object ( [status] => ok ) [invoice] => stdClass Object ( [invoice_id] => 00000219023 [estimate_id] => stdClass Object ( ) [number] => 8822 [client_id] => 83 [contacts] => stdClass Object ( [contact] => stdClass Object ( [contact_id] => 0 ) ) [recurring_id] => stdClass Object ( ) [organization] => Jimmy Thwart [first_name] => stdClass Object ( ) [last_name] => stdClass Object ( ) [p_street1] => stdClass Object ( ) [p_street2] => stdClass Object ( ) [p_city] => stdClass Object ( ) [p_state] => stdClass Object ( ) [p_country] => stdClass Object ( ) [p_code] => stdClass Object ( ) [po_number] => 10002 [status] => sent [amount] => 16.90 [amount_outstanding] => 16.90 [paid] => 0.00 [date] => 2013-01-31 00:00:00 [notes] => stdClass Object ( ) [terms] => Your slot can only be secured upon payment. Any reservation made before payment will only be guaranteed for 2 days. [discount] => 0 [url] => https://example.freshbooks.com/view/vgPb2TNGCR7n8JV [auth_url] => https://example.freshbooks.com/invoices/219023 [links] => stdClass Object ( [client_view] => https://example.freshbooks.com/view/vgPb2TNGCR7n8JV [view] => https://example.freshbooks.com/invoices/219023 [edit] => https://example.freshbooks.com/invoices/219023/edit ) [return_uri] => stdClass Object ( ) [updated] => 2013-01-31 02:25:13 [currency_code] => SGD [language] => en [vat_name] => stdClass Object ( ) [vat_number] => stdClass Object ( ) [folder] => active [staff_id] => 1 [lines] => stdClass Object ( [line] => stdClass Object ( [line_id] => 1 [name] => Lady 1pax [description] => Services (1 pax) [unit_cost] => 16.90 [quantity] => 1 [amount] => 16.90 [tax1_name] => stdClass Object ( ) [tax2_name] => stdClass Object ( ) [tax1_percent] => 0 [tax2_percent] => 0 [compound_tax] => 0 [type] => Item ) ) [gateways] => stdClass Object ( [gateway] => stdClass Object ( [name] => PayPal ) ) ) ) 

出力が URL のみであり、このコード全体ではないことを願っています。必要な出力:

https://example.freshbooks.com/view/vgPb2TNGCR7n8JV

ただし、請求書のすべての情報がリストされます。請求書の URL だけを取得するにはどうすればよいですか?

4

2 に答える 2

0

Invoice はクラスのインスタンスです。すべてのインスタンスと同じように扱う必要があります。

URL 値を取得するには、次のようにします。

<?php
$invoice_id=118868;

$invoice=$freshbooks->invoiceGet($invoice_id);
print $invoice->url;
?>

または、探している別の可能な値があります。

<?php
$invoice_id=118868;

$invoice=$freshbooks->invoiceGet($invoice_id);
print $invoice->links->client_view;
?>

公式の API ドキュメント によると<url>、これ以上サポートしていないため、<links>「要素を使用して、編集、クライアントによる表示、および管理者による表示のために請求書への直接リンクを顧客に提供する」必要があります。

于 2013-01-31T07:56:42.273 に答える
0

コードの出力を使用すると、 の要素が何であるかがわかります$invoice。必要なものを使用してください。

于 2013-01-31T07:06:01.247 に答える