Zoho 获取发票

Zoho Get an Invoice

我正在尝试将 zoho 与我的网络应用程序集成。我正在拨打 api 电话以获取特定发票。根据文档的调用是

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

这也很好用。但是当我为 INVOICE ID 设置一个变量时,它 returns 所有发票。 (200 INVOICES)电话如下。

'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);
}

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

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