diff -r 7c67caaafdeb -r 761ba7426984 web/tweet_ajax.php --- a/web/tweet_ajax.php Mon Nov 20 18:10:58 2023 +0100 +++ b/web/tweet_ajax.php Tue Sep 03 11:09:40 2024 +0200 @@ -1,14 +1,13 @@ "https://$domain", + 'timeout' => 2.0, + ]); + $resp = $client->post("/api/v1/statuses", [ + 'headers' => [ + 'Authorization' => 'Bearer ' . $token, + 'Accept' => 'application/json', + 'Idempotency-Key' => hash('sha256', $status), + ], + 'form_params' => [ 'status' => $status ], + ]); + echo('true'); +} + + +/** + * Check for a POSTed status message to send to Twitter + */ +if ( + !empty($_POST) && isset($_POST['status']) + && isset($_SESSION['SOCIAL_ACCESS_TOKEN']) +) { + + $socialNetwork = isset($_POST['social_network']) ? $_POST['social_network'] : "Twitter"; + + if ($socialNetwork == "Twitter") { + sendTwitter(); + } else { + sendMastodon(); + } } else { /** * Mistaken request? Some malfeasant trying something?