-
Notifications
You must be signed in to change notification settings - Fork 0
/
bsky-api-auth.php
26 lines (23 loc) · 976 Bytes
/
bsky-api-auth.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
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['handle']) && isset($_POST['randomString'])) {
$handle = $_POST['handle'];
$randomString = $_POST['randomString'];
$apiUrl = '/bsky-local-api.php?handle=' . urlencode($handle);
$postResponse = file_get_contents($apiUrl);
if ($postResponse !== false) {
$postData = json_decode($postResponse);
if ($postData && isset($postData->feed) && count($postData->feed) > 0 && isset($postData->feed[0]->post->record->text)) {
$postText = $postData->feed[0]->post->record->text;
if ($postText === $randomString) {
echo json_encode(array("status" => "success"));
} else {
echo json_encode(array("status" => "fail"));
}
} else {
echo json_encode(array("status" => "error"));
}
} else {
echo json_encode(array("status" => "error"));
}
}
?>