Extract response header via curl in php

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
// ...

$response = curl_exec($ch);

// Then, after your curl_exec call:
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);

https://stackoverflow.com/questions/9183178/can-php-curl-retrieve-response-headers-and-body-in-a-single-request

CloudFlare API remark

By default , CloudFlare doesn`t support CNAME record for free plan, instead of NS record.But CNAME is more flexible ! I discover the cloudflare API website and find some APIS can create a CNAME record(but i got an error by create CNAME record)

First , Get you zones id

$ curl -X GET “https://api.cloudflare.com/client/v4/zones” \
-H “X-Auth-Email: [your cloudflare email]” \
-H “X-Auth-Key: [you cloudflare API key]” \
-H “Content-Type: application/json”

Second , Create a CNAME record , But I got an error . I will try to solve it soon.

$ curl -X POST “https://api.cloudflare.com/client/v4/zones/[you zone id get via above request]/custom_hostnames” \
-H “X-Auth-Email: [you cloudflare email]” \
-H “X-Auth-Key: [you cloudflare API key]” \
-H “Content-Type: application/json” \
–data ‘{“hostname”:”[you host like test.abc.com]”,”ssl”:{“method”:”http”,”type”:”dv”,”settings”:{“http2″:”on”,”min_tls_version”:”1.2″,”tls_1_3″:”on”,”ciphers”:[“ECDHE-RSA-AES128-GCM-SHA256″,”AES128-SHA”]}}}’