I have some documentation for an API system and it is telling me to send a PUT Request to a service URL, they have provided this:
PUT /domain/manage/renew/{domain_name}/{period}
along with the main URL to send the request to.
I thought to do this i would need to use cURL
so I created the following:
$data = array("a" => $a);
$ch = curl_init($this->_serviceUrl . $id);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($data));
$response = curl_exec($ch);
if(!$response) {
return false;
}
but they have also said:
The HTTP request header must contain the User, Hash and Encryption.
User: <username>
Hash: <authentication_hash>
Encryption: SHA-512
My question is:
{domain_name}
and {period}
as per the url above?** UPDATED **
Send the headers like this:
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'User: '.$user, // change the variables to whatever you need, i.e. $this->user or whatever
'Hash: '.$hash, // same here
'Encryption: SHA-512'
]);
$response = curl_exec($ch);
if(!$response) {
return false;
}
As for the URL, do something like this:
$ch = curl_init('http://www.example.com/domain/manage/renew/'.urlencode($domain_name).'/'.urlencode($period));