php - Zoho Books API 添加估算

标签 php curl zoho zohobooks

我对 Zoho API 和curl 都很陌生。我正在尝试开发一个能够使用 Zoho Books API 为客户创建估算的类,但是当我运行代码时,我不断收到 bool 错误响应 >> enter image description here 。请告诉我我做错了什么,并引导我访问一个包含适当教程的网站。

    $data = array(
        'authtoken'         => 'xxxxxxxxxx',
        'JSONString'        => '{
  "customer_id": "157691000000041090",
  "contact_persons": [
    "157691000000041090"
  ],
  "template_id": "157691000000041077",
  "estimate_number": "EST-000001",
  "reference_number": "QRT-123456",
  "date": "2015-08-25",
  "expiry_date": "2015-08-27"
  "exchange_rate": 1.0,
  "discount": 0.0,
  "is_discount_before_tax": true,
  "discount_type": "item_level",
  "salesperson_name": "John Michael",
  "is_inclusive_tax": "false",
  "custom_fields": [
    {
      "index": 1,
      "value": "25 Aug 2015"
    }
  ],
  "line_items": [
    {
      "item_id": "157691000000041080",
      "name": "Book1",
      "description": "book",
      "rate": 50.00,
      "item_order": 0,
      "quantity": 1.0,
      "discount": 0.0,
      "tax_id": "",
    }
  ],
  "notes": "Looking forward for your business.",
  "terms": "Terms and conditions apply.",
  "shipping_charge": 0.0,
  "adjustment": 0.0,
  "adjustment_description": "Adjustment"
}',
        "organization_id"   => '57408606'
    );

    $curl = curl_init($url);

    curl_setopt_array($curl, array(
      CURLOPT_POST => 1,
      CURLOPT_POSTFIELDS => $data,
      CURLOPT_RETURNTRANSFER => true
    ));

    $estimate = curl_exec($curl);
var_dump($estimate)

最佳答案

看起来 JSON 的格式不正确。请进行以下更改并让我知道它是否有效

1) 在

后添加“,”

"expiry_date": "2015-08-27"

2) 删除

后的“,”

"tax_id": "",

关于php - Zoho Books API 添加估算,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32201636/

相关文章:

php - Laravel 中具有多对多关系的工厂种子数据透视表

html - 在 MAILGUN 上通过 cURL 发送 HTML

java - 使用 Jersey 在 REST 服务中上传多个文件

mysql - 重命名 PostgreSQL 或任何 SQL 中的项目

zoho - 如何在zoho中进行json解码

php - 将数据加载到水平时间线中

php - 帮助我的正则表达式

PHP,从 mysql 表中选择尚未选择的随机行!

php cURL 问题

django - 通过zoho发送smtp邮件连接超时错误