我的代码如下......
电子邮件功能
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);
}
创建发票,联系人和发送电子邮件的卷曲功能
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”:“无效的网址已通过”}
请帮帮我....
提前致谢...
答案 0 :(得分:2)
您的代码运行正常。尝试打印网址($url
)并确认其是否为所需格式(/invoices/invoice_id/email
)。例如,如果您的invoice_id为1234,则$url
应为“/invoices/1234/email
”。另外,请确保$this->apiUrl
为https://books.zoho.com/api/v3
如果出现问题,您仍然可以使用下面提到的帮助文档:
答案 1 :(得分:1)
您是否尝试过使用完整网址:&#34; https://books.zoho.com/api/v3/invoices/:invoiceno/email&#34;