Reputation: 2424
I am trying to use the CloudFlare API via PHP CURL however the doc examples show as command line curl.
$ curl -X PUT "https://api.cloudflare.com/client/v4/zones/9a7806061c88ada191ed06f989cc3dac/dns_records/9a7806061c88ada191ed06f989cc3dac" \
-H "X-Auth-Email: [email protected]" \
-H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \
-H "Content-Type: application/json" \
--data '{"id":"9a7806061c88ada191ed06f989cc3dac","type":"A","name":"example.com","content":"1.2.3.4","proxiable":true,"proxied":false,"ttl":120,"locked":false,"zone_id":"9a7806061c88ada191ed06f989cc3dac","zone_name":"example.com","created_on":"2014-01-01T05:20:00.12345Z","modified_on":"2014-01-01T05:20:00.12345Z","data":{}}'
Is the PUT request the same as POST? And the array at the bottom is confusing me. No idea how that translates to PHP CURL.
Upvotes: 3
Views: 1587
Reputation: 18550
You will need to do a post but also send a custom request. Curl will then do a post style put
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
Then add the headers if needed
curl_setopt($ch, CURLOPT_HTTPHEADER, [array of your headers]);
Change the array to be a key value array where the key is the header name and value is the header value
Upvotes: 1