okay maybe fedi posts work

This commit is contained in:
notfire 2024-12-09 17:33:37 -05:00
parent 733f24964c
commit a98d9316ba
No known key found for this signature in database
GPG key ID: 3AFDACAAB4E56B16
3 changed files with 45 additions and 1 deletions

34
admin/fedi.php Normal file
View file

@ -0,0 +1,34 @@
<?php
$query = "
SELECT * FROM data
WHERE id = {$id};
";
$qresp = pg_query($db, $query);
$arr = pg_fetch_array($qresp);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$fediAPIRoute);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,
array("Authorization: {$fediAPIToken}"));
$contentO = $arr["text"];
$contentR = $arr["responsetext"];
if ($arr["iscwed"]) {
$contentCW = $arr["cw"];
curl_setopt($ch, CURLOPT_POSTFIELDS,
http_build_query(array('status' => "question: {$contentO}\nresponse: {$contentR}", 'visibility' => "{$fediVisibility}", 'spoiler_text' => "anonymous requestion response (automated); cw: {$contentCW}")));
} else {
curl_setopt($ch, CURLOPT_POSTFIELDS,
http_build_query(array('status' => "question: {$contentO}\nresponse: {$contentR}", 'visibility' => "{$fediVisibility}", 'spoiler_text' => "anonymous requestion response (automated)")));
}
curl_exec($ch);
curl_close($ch);
?>

View file

@ -15,8 +15,12 @@ if ($_GET["text"] !== null) {
WHERE id = {$id};
";
pg_query($db, $query);
if ($fediEnabled) {
include 'fedi.php';
}
header("Location: index.php?responded=1&pw={$adminPassword}");
}

View file

@ -15,6 +15,12 @@ $pageDomainOther = $pageDomain; // you can comment out and change this to a subd
//$pageDomainOther = "me.example.com";
$pageRoot = "/"; // path to go to
// post to fedi?
$fediEnabled = False;
$fediAPIRoute = "https://example.com/api/v1/statuses";
$fediAPIToken = "Bearer AUTHTOKENGOESHERE";
$fediVisibility = "private";
// database setup
$dbHost = "localhost";
$dbName = "postgres";