Skip to content

Instantly share code, notes, and snippets.

@Cojad
Last active September 4, 2017 04:40
Show Gist options
  • Save Cojad/65e70fa4ddfc3372ad38245f9a063388 to your computer and use it in GitHub Desktop.
Save Cojad/65e70fa4ddfc3372ad38245f9a063388 to your computer and use it in GitHub Desktop.
update Cloudflare with PHP file wrapper
<?php
$postdata = array(
'type' => 'A',
'name' => 'a.xxx.tw', //你的domain name
'content' => '123.123.123.123' // 你要更新的對應ip地址
);
$opts = array('http' =>
array(
'method' => 'PUT',
'header' => "X-Auth-Email: 你的信箱@gmail.com\r\n" .
"X-Auth-Key: xxxxxxxxxxxxxxxxxxxxx__你的AuthKey__xx\r\n" .
"Content-type: application/json\r\n",
'content' => json_encode($postdata)
)
);
$context = stream_context_create($opts);
$result = file_get_contents('https://api.cloudflare.com/client/v4/zones/__你的zone_identifier__xxxxxxxxxxxx/dns_records/__你的RECORDID__xxxxxxxxxxxxxxxxxx', false, $context);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment