I have a problem with sending a request to a remote api - the error message:
Object reference not set to an instance of an object
<?php
$xml_data ="<?xml version='1.0' encoding='utf-16' ?>
<ChameleonIAPI>
<Method>SearchVacancies</Method>
<APIKey>apikey</APIKey>
<UserName>user</UserName>
<Filter>
<Param Name='Permanent' Value='True' />
<Param Name='Contract' Value='True' />
<Param Name='Temporary' Value='True' />
<Param Name='PageNo' Value='1' />
<Param Name='PageSize' Value='10000' />
<Param Name='TagIDCSV' Value='!AND215476' />
</Filter>
</ChameleonIAPI>";
$action = "postxml";
$authkey = "key";
$authpassword = "pass";
$URL = "http://path/to/url/PostXml.aspx";
$ch = curl_init($URL);
//curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "Action=".$action."&AuthKey=".$authkey."&AuthPassword=".$authpassword."&xml=".$xml_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
$output = curl_exec($ch);
curl_close($ch);
?>
0 comments:
Post a Comment