-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgetall.php
35 lines (27 loc) · 876 Bytes
/
getall.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
get<?php
$gist_id = "b826243c4d043c86ca23b29a86f5aa81"; // Replace with the Gist ID you want to fetch
$api_url = "https://api.github.com/gists/$gist_id";
$curl = curl_init($api_url);
$headers = [
'User-Agent: YourAppName', // Replace with your app name
'Content-Type: application/json',
];
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if ($status == 200) {
$gist = json_decode($response, true);
foreach ($gist['files'] as $file) {
$filename = $file['filename'];
$content = $file['content'];
echo "File Name: $filename\n";
echo "Content:\n";
echo $content;
echo "\n\n";
}
} else {
echo "Failed to fetch Gist. HTTP Status Code: $status";
}
?>