1

我的代码如下...

电子邮件功能

public function zoho_email($array){
$data = json_decode($array,true);       
                $url = '/invoices/'.$data['invoice']['invoice_id'].'/email';
                $recivers[] =   array($data['invoice']['contact_persons_details'][0]['email']);
                $data = array(
                    'to_mail_ids'               => $recivers,
                    'subject'                   => 'Invoice from MSL (Invoice#: '.$data['invoice']['invoice_number'].')',
                    'body'                      => 'Dear Customer,<br><br><br><br>Thanks for your business,
                    'send_from_org_email_id'    => true
                );      
                $result = $this->zoho_create($url, $data);

            }

curl 用于创建发票、联系人和发送电子邮件的函数

        public function zoho_create($url,$array){   
                $json = json_encode($array);
                $data = array('authtoken' => ZOHOAUTHTOKEN,'JSONString' => $json,'organization_id'  => ZOHOORGNISATIONID);
                $curl = curl_init($this->apiUrl.$url);
                if($url=='contacts/'){
                    curl_setopt_array($curl, array(
                        CURLOPT_POST => 1,
                        CURLOPT_POSTFIELDS => $data,
                        CURLOPT_RETURNTRANSFER => true
                    ));
                }
                else{
                    curl_setopt($curl, CURLOPT_VERBOSE, 1);
                    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
                    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); 
                    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
                    curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
                    curl_setopt($curl, CURLOPT_POST, TRUE);
                    curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded") );          
                }
                $response = curl_exec($curl);
                curl_close($curl);
                return $response;
            }

我想通过 API 通过电子邮件向客户发送发票,但我的代码中出现此错误。

{"code":5,"message":"无效的 URL 已通过"}

请在那里帮我....

提前致谢...

4

2 回答 2

2

您的代码工作正常。尝试打印 url ( $url) 并确认一次是否为所需格式 ( /invoices/invoice_id/email)。例如,如果您的 invoice_id 是 1234,那么$url应该是 ' /invoices/1234/email'。还要确保这$this->apiUrlhttps://books.zoho.com/api/v3

如果仍然出现问题,您可以使用下面提到的帮助文档:

https://www.zoho.com/books/api/v3/

于 2017-02-08T13:44:20.780 回答
1

您是否尝试过使用完整的网址:“ https://books.zoho.com/api/v3/invoices/:invoiceno/email

于 2017-02-08T09:47:37.933 回答