okay maybe fedi posts work
This commit is contained in:
parent
733f24964c
commit
a98d9316ba
3 changed files with 45 additions and 1 deletions
34
admin/fedi.php
Normal file
34
admin/fedi.php
Normal 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);
|
||||
|
||||
?>
|
|
@ -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}");
|
||||
}
|
||||
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Reference in a new issue