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("Successfuly 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);
}
?>Validation of your xml
You should validate your xml file using the following XSD: - 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 in command line: - Download libxml2 for your operationg system and install or unpack from: http://xmlsoft.org/downloads.html - Download both xsd in web browser or in 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 (import.xml is validated XML file):
bin/xmllint.exe --schema ei_std_jd_2006-10-19.xsd import.xml --nooutWhen see this output then is XML valid:
import.xml validatesSee another tools and value lists section.
Last updated on