title: “Demonstration PHP script” description: API description of Teamio Vacancies Import API
Demonstration PHP script for uploading XML of vacancy
<?php
/**
* Alma Career Demonstration PHP script for uploading XML imports to ATS Teamio
*
* @version $Id: 1.0.1 $
* @package lmc_sys
* @subpackage upload
* @access public
*/
/**
* Settings part, modify as necessary...
*/
$auth = array('login' => 'importlogin1', 'password' => '123456', 'url' => 'custompath');
$lXmlFile = "./test.xml";
$lUrl = 'https://g2.lmc.cz/import/' . $auth['url'] . '/import';
/**
* Working part, do not modify it...
*/
$lHttpPost = array('username' => $auth['login'], 'password' => $auth['password'], 'url' => [$lUrl], 'xmlString' => "");
if ($lHttpPost['xmlString'] = file_get_contents($lXmlFile)) {
if (!$lReq = curl_init($lUrl)) die("Not able to connect to: " . $lUrl);
curl_setopt($lReq, CURLOPT_POST, TRUE);
curl_setopt($lReq, CURLOPT_SSL_VERIFYPEER, 0);
$lPostStr = http_build_query($lHttpPost);
curl_setopt($lReq, CURLOPT_POSTFIELDS, $lPostStr);
curl_setopt($lReq, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($lReq, CURLOPT_FAILONERROR, TRUE);
$lResult = curl_exec($lReq);
if ($lResult) die("Successfully uploaded!\n " . $lResult);
else die("server error: Not able to send data to: " . $lUrl . " , error message: " . curl_error($lReq));
curl_close($lReq);
} else {
die("Not able to read input XML file!\n " . $lXmlFile);
}
?>XML Validation
You should validate your XML file using the following XSD schemas: - http://schema.lmc.cz/ei_std/xsd/ei_std_jd_2006-10-19.xsd - http://schema.lmc.cz/ei_std/xsd/enumerationType.xsd
For example, use xmllint from the command line: - Download libxml2 for your operating system and install or unpack from: http://xmlsoft.org/downloads.html - Download both XSD schemas in a web browser or from the Linux command line:
curl -o http://schema.lmc.cz/ei_std/xsd/ei_std_jd_2006-10-19.xsd
curl -o http://schema.lmc.cz/ei_std/xsd/enumerationType.xsdRun xmllint from libxml2 (where import.xml is the XML file to be validated):
bin/xmllint.exe --schema ei_std_jd_2006-10-19.xsd import.xml --nooutWhen you see this output, the XML is valid:
import.xml validatesSee the Tools and Value Lists section for more information.
Last updated on