-
Notifications
You must be signed in to change notification settings - Fork 6
/
media_bot.php
30 lines (21 loc) · 984 Bytes
/
media_bot.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
include_once 'Mastodon.php';
$token = 'XXXXX'; // Token of your Mastodon welcome bot account
$base_url = 'https://botsin.space'; // URL of your instance (Do not include '/' at the end.)
$visibility = 'private'; // "Direct" means sending welcome message as a private message. The four tiers of visibility for toots are Public , Unlisted, Private, and Direct (default)
$language = 'en'; // en for English, zh for Chinese, etc.
$mastodon = new MastodonAPI($token, $base_url);
$curl_file = curl_file_create('./imageOnServer.jpg', 'image/jpg', 'imagename.jpg');
$body = [
'file' => $curl_file,
];
$response = $mastodon->uploadMedia($body);
$file_id = $response['id'];
$statusText = 'This is a status';
$status_data = [
'status' => $statusText,
'visibility' => $visibility,
'language' => $language,
'media_ids[]' => $file_id,
];
$mastodon->postStatus($status_data);