Compare commits

...

7 Commits

Author SHA1 Message Date
Grimstack e8dc19ccb8
Fix repo url styleCi in Readme 2022-12-17 18:54:13 +01:00
Grimstack 314f677464
Merge pull request #7 from Eleirbag89/analysis-rrv2aG
Apply fixes from StyleCI
2022-12-17 18:51:33 +01:00
StyleCI Bot 4d2c88606b
Apply fixes from StyleCI 2022-12-17 17:51:20 +00:00
Grimstack 2bbf91d831
Merge pull request #6 from sbsatwork/patch-1
Fixed definition of $header
2022-12-17 18:50:39 +01:00
Grimstack 9d27ce38e8
Merge pull request #3 from sbsatwork/patch-3
Simple example for posting a status update
2022-12-17 18:46:55 +01:00
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
sbsatwork 6b8de0222c
Fixed definition of $header
Removed the "," at the end of the $header-definition, since this made the script stop working
2022-12-16 16:26:44 +01:00
4 changed files with 27 additions and 6 deletions

View File

@ -4,7 +4,7 @@
[![Total Downloads](https://poser.pugx.org/eleirbag89/mastodonbotphp/downloads)](https://packagist.org/packages/eleirbag89/mastodonbotphp)
[![License](https://poser.pugx.org/eleirbag89/mastodonbotphp/license)](https://packagist.org/packages/eleirbag89/mastodonbotphp)
[![StyleCI](https://styleci.io/repos/254720352/shield?branch=master)](https://styleci.io/repos/38492095)
[![StyleCI](https://styleci.io/repos/254720352/shield?branch=master)](https://styleci.io/repos/254720352)
A very simple PHP Mastodon API for sending statuses
@ -89,4 +89,4 @@ Support me
You can support me using via LiberaPay [![Donate using Liberapay](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/eleirbag89/donate)
or buy me a beer or two using [Paypal](https://paypal.me/eleirbag89).
or buy me a beer or two using [Paypal](https://paypal.me/eleirbag89).

View File

@ -11,7 +11,7 @@
$tagline = ' check out on ';
if (!($jsonTxt = file_get_contents($feed_url))) {
die('Error loading the feed url');
exit('Error loading the feed url');
}
$json = json_decode($jsonTxt, true);
@ -38,7 +38,7 @@
array_push($statuses, $post);
if (!$first_article) {
$myfile = fopen($file, 'w') or die('Unable to open file!');
$myfile = fopen($file, 'w') or exit('Unable to open file!');
fwrite($myfile, $ts);
fclose($myfile);
$first_article = true;

View File

@ -10,7 +10,7 @@
$file = 'data.txt';
if (!($rss = simplexml_load_file($feed_url))) {
die('Error loading the feed url');
exit('Error loading the feed url');
}
$first_article = false;
@ -35,7 +35,7 @@
array_push($statuses, $post);
if (!$first_article) {
$myfile = fopen($file, 'w') or die('Unable to open file!');
$myfile = fopen($file, 'w') or exit('Unable to open file!');
fwrite($myfile, $ts);
fclose($myfile);
$first_article = true;

21
examples/status_bot.php Normal file
View File

@ -0,0 +1,21 @@
<?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 = [
'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);