Php 通过Zoho Books API通过电子邮件发送发票
我的代码如下 电子邮件功能Php 通过Zoho Books API通过电子邮件发送发票,php,api,email,cakephp-2.0,zohobooks,Php,Api,Email,Cakephp 2.0,Zohobooks,我的代码如下 电子邮件功能 public function zoho_email($array){ $data = json_decode($array,true); $url = '/invoices/'.$data['invoice']['invoice_id'].'/email'; $recivers[] = array($data['invoice']['contact_persons_details'][
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);
}
我想通过API通过电子邮件向客户发送发票,但我的代码中出现了此错误
{“代码”:5,“消息”:“传递的URL无效”}
请帮帮我
提前感谢…您是否尝试使用完整url:“您的代码工作正常。尝试打印url(
$url
)并确认它是否为所需格式(/invoices/invoices\u id/email
)。例如,如果您的发票id为1234,则$url
应为“/invoices/1234/email
”。还要确保$this->apirl
是https://books.zoho.com/api/v3
如果出现问题,您仍然可以使用下面提到的帮助文档:
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;
}