在2018年,GitHub停止支持匿名摘要(直到我使用了这段代码:
$content = '<html>something... </html>';
$url = 'https://api.github.com/gists';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch, CURLOPT_POST, 1);
$header[]= "User-Agent: My App Name,Website or Email (for identification)";
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$data = array(
"description"=> "descr",
"public"=> true,
"files" => [
"file1.txt"=> [
"content" => $content
]
]
);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data) );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch); curl_close($ch);
// result ---> $response;
现在,它需要授权才能创建要点。我想不出一个简单易用的完整示例,现在如何创建要点。