1
0
mirror of https://github.com/Eleirbag89/MastodonBotPHP synced 2025-01-06 18:06:42 +01:00
Mastodon-Bot-PHP/examples/status_bot.php
sbsatwork 812a450306
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.
2022-12-16 16:33:33 +01:00

23 lines
742 B
PHP

<?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);
?>