Zoho 获取发票

发布于 2025-01-15 01:27:10 字数 1118 浏览 3 评论 0原文

我正在尝试将 zoho 与我的网络应用程序集成。我正在进行 api 调用来获取特定发票。根据文档进行的调用是

'https://books.zoho.com/api/v3/invoices/INV_ID?organization_id=XXXXXXXX'

这也可以正常工作。但是当我为发票 ID 设置变量时,它会返回所有发票。 (200 张发票)电话如下。

'https://books.zoho.com/api/v3/invoices/' .$inv_id. '?organization_id=XXXXXXXX';

我在哪里犯了错误?方法如下。

$zid = '';
if(isset($_POST['_zid'])){
    $zid = $_POST['_zid'];
}
get_invoice($access_token, $zid);
function get_invoice($access_token, $zid){
    $invid = $zid;
    $service_url = $GLOBALS['service_url'] . 'https://books.zoho.com/api/v3/invoices/' .$invid. '?organization_id=XXXXXXXXX';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_URL, $service_url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Authorization: Zoho-oauthtoken '. $access_token,
        'Content-Type: "application/json"'));
    $res = curl_exec($ch);
    curl_close($ch);
    $dec_res = array();
    $dec_res = json_decode($res, true);
    print_r($dec_res);
}

I am trying to integrate zoho with my web app. I am making an api call to get a particular invoice. The call as per documentation is

'https://books.zoho.com/api/v3/invoices/INV_ID?organization_id=XXXXXXXX'

This works fine as well. But when I set a variable for INVOICE ID, it returns all the invoices. (200 INVOICES) The call is below.

'https://books.zoho.com/api/v3/invoices/' .$inv_id. '?organization_id=XXXXXXXX';

where I am making the mistake? The method is below.

$zid = '';
if(isset($_POST['_zid'])){
    $zid = $_POST['_zid'];
}
get_invoice($access_token, $zid);
function get_invoice($access_token, $zid){
    $invid = $zid;
    $service_url = $GLOBALS['service_url'] . 'https://books.zoho.com/api/v3/invoices/' .$invid. '?organization_id=XXXXXXXXX';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_URL, $service_url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Authorization: Zoho-oauthtoken '. $access_token,
        'Content-Type: "application/json"'));
    $res = curl_exec($ch);
    curl_close($ch);
    $dec_res = array();
    $dec_res = json_decode($res, true);
    print_r($dec_res);
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绅刃 2025-01-22 01:27:10

一切都很好,除了一件小事。我没有想到数组声明。工作调用直接被赋予一个整数作为invoice_id。当我传递声明为字符串的变量时。因此,尽管数字被视为字符串,这使得调用无效。

//THIS WILL DO THE TRICK
$zid = 0;
if(isset($_POST['_zid'])){
    $zid = $_POST['_zid'];
}

Everything is fine except a small thing. I didn't think of Array Declaration. The working call is straightly given an integer as the invoice_id. when I pass the variable declared as a string. so although the digits it is counted as a string which makes the call invalid.

//THIS WILL DO THE TRICK
$zid = 0;
if(isset($_POST['_zid'])){
    $zid = $_POST['_zid'];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文