Simple example for posting a status update

Created a new example script to show how to simply post a plain text status update to a Mastodon account.
This commit is contained in:
sbsatwork 2022-12-16 16:33:33 +01:00 committed by GitHub
parent cf70522a80
commit 812a450306
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 0 deletions

22
examples/status_bot.php Normal file
View File

@ -0,0 +1,22 @@
<?php
include_once 'Mastodon.php';
$token = ''; // Token of your Mastodon bot account
$baseURL = 'https://botsin.space'; // URL of your instance (Do not include '/' at the end.)
$privacy = 'private'; // "Direct" means sending message as a private message. The four tiers of privacy for toots are public , unlisted, private, and direct
$language = 'en'; // en for English, zh for Chinese, de for German etc.
$statusText = 'This is a status';
$statusData = array(
'status' => $statusText,
'privacy' => $privacy,
'language' => $language
);
$mastodon = new MastodonAPI($token, $baseURL);
$result = $mastodon->postStatus($statusData);
// Activate the next line if you want to print the result of the query
//var_dump($result);
?>