I' m trying to build a php script that post other webservice I'm using culr as you can see, the issue is in the API webserver docs ask me to send some header parameters, literally "For each http call you will need to add the following header parameters: APIuserID, APIpassword and ResponseType"
so my question is how can I add custom parameters to my header request?. thanks
<?php
function curl_post($url, array $post = NULL, array $options = array())
{
$defaults = array(
CURLOPT_POST => 1,
CURLOPT_HEADER => 0,
CURLOPT_URL => $url,
CURLOPT_FRESH_CONNECT => 1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_FORBID_REUSE => 1,
CURLOPT_TIMEOUT => 4,
CURLOPT_SSL_VERIFYHOST=>0,
CURLOPT_POSTFIELDS => http_build_query($post)
);
$ch = curl_init();
curl_setopt_array($ch, ($options + $defaults));
if( ! $result = curl_exec($ch))
{
trigger_error(curl_error($ch));
}
curl_close($ch);
return $result;
}
$result=curl_post('https://www.serverPath/serverAPI',array('a'=>'a','b'=>'b'));
echo $result;
?>