I'm trying to connect a linkedin signup to an addition to Zoho's Recruit API
When I use requestbin, It seems like it should work, but when I submit to Zoho, I get an error, could not parse data type.
This is where the info was on how to structure an xml post to zoho's api
https://www.zoho.com/recruit/add-records.html
Below is what my code looks like. Any advice on what I'm doing wrong?
<?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);
?>