public function sendLeadZoho($token, $params){
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
$xml .= '<Leads>';
$xml .= '<row no="1">';
$xml .= '<FL val="Lead Source">APP TECNICOS</FL>';
foreach($params as $param){
if($param['key']){
$xml.='<FL val="'.$param['key'].'">'.$param['value'].'</FL>';
}
}
$xml .= '</row>';
$xml .= '</Leads>';
$url ="https://crm.zoho.com/crm/private/xml/Leads/insertRecords";
$query="authtoken=".$token."&scope=crmapi&newFormat=1&xmlData=".$xml;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
$api->sendLeadZoho('Our_ZSC_Key',[
['key'=>'First Name' , 'value' =>$name ],
['key'=>'Last Name' , 'value' =>$apellidos ],
['key'=>'Email' , 'value' =>$email ],
['key'=>'Phone' , 'value' =>$tel ],
['key'=>'Company' , 'value' =>$company ],
['key'=>'Industry' , 'value' =>$industry ]
]);