Hi there,
I'm currently migrating some code to manage DNS records using Gandi's new
Live DNS api. (was xml-rpc before, regular ReST now)
The issue I'm having is that when using Web->request() to run a POST request, there's no response output. In fact the process seems to hang and I have to "CTRL+C" to exit.
Here's the code using PHP's native cURL functions.
This works and returns the correct output. (success message from API)
$url = $this->host . 'domains/' . $this->domain . '/records';
$record = json_encode([
'rrset_name' => $name,
'rrset_type' => $type,
'rrset_ttl' => $ttl,
'rrset_values' => [$value]
]);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $record);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-Api-Key:' . $this->key,
'Content-Type: application/json',
'Content-Length: ' . strlen($record)
]);
$result = curl_exec($ch);
return $result;
Now here's (what I assume) the equivalent using F3's Web class.
This works in the sense that the API does what it should, but it just hangs there until I break it and there's no output.
$url = $this->host . 'domains/' . $this->domain . '/records';
$record = json_encode([
'rrset_name' => $name,
'rrset_type' => $type,
'rrset_ttl' => $ttl,
'rrset_values' => [$value]
]);
$options = [
'method' => 'POST',
'header' => [
'X-Api-Key:' . $this->key,
'Content-Type: application/json',
'Content-Length: ' . strlen($record)
],
'content' => $record
];
$result = \Web::instance()->request($url, $options);
return $result;
Using
Postman (the api testing app) the request also runs without any issues and returns the API success message.
Any ideas or is there any way to better debug or log the request in order to figure out what's going on?
Thanks.