我正在尝试将链接的注册连接到 Zoho 的 Recruit API 的附加内容
当我使用 requestbin 时,它似乎应该可以工作,但是当我提交给 Zoho 时,我得到一个错误,无法解析数据类型。
这是有关如何将 xml 帖子构建到 zoho 的 api 的信息的地方
https://www.zoho.com/recruit/add-records.html
下面是我的代码的样子。关于我做错了什么有什么建议吗?
<?php
$post_body = file_get_contents('php://input');
$application = json_decode($post_body);
//shortcodes
$firstname = $application->person->firstName;
$lastname = $application->person->lastName;
$city = $application->location->name;
$email = $application->person->emailAddress;
$headline = $application->person->headline;
/*
* XML Sender/Client.
*/
// Get our XML. You can declare it here or even load a file.
$xml_builder = "
<Candidates>
<row no=\"1\">
<FL val=\"First name\">{$firstname}</FL>
<FL val=\"Last name\">{$lastname}</FL>
<FL val=\"Contact address\">{$lastname}</FL>
<FL val=\"Email ID\">{$email}</FL>
<FL val=\"Current job title\">{$headline}</FL>
</row>
</Candidates>
";
// Initialize curl
$curl = curl_init();
$opts = array(
CURLOPT_URL => 'https://recruit.zoho.com/ats/private/xml/Candidates/addRecords?authtoken=#secrettoken&scope=recruitapi&duplicateCheck=1&xmlData={$xml_builder}',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $xml_builder,
CURLOPT_HTTPHEADER => array('Content-Type: text/xml','Content-Length: ' . strlen($xml_builder))
);
// Set curl options
curl_setopt_array($curl, $opts);
// Get the results
$result = curl_exec($curl);
// Close resource
curl_close($curl);
echo $result;
$fp = fopen('zoho.txt', 'w');
fwrite($fp, $result);
fclose($fp);
?>