Compare commits
7 Commits
cf70522a80
...
e8dc19ccb8
Author | SHA1 | Date |
---|---|---|
Grimstack | e8dc19ccb8 | |
Grimstack | 314f677464 | |
StyleCI Bot | 4d2c88606b | |
Grimstack | 2bbf91d831 | |
Grimstack | 9d27ce38e8 | |
sbsatwork | 812a450306 | |
sbsatwork | 6b8de0222c |
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
[![Total Downloads](https://poser.pugx.org/eleirbag89/mastodonbotphp/downloads)](https://packagist.org/packages/eleirbag89/mastodonbotphp)
|
[![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)
|
[![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
|
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)
|
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).
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
$tagline = ' check out on ';
|
$tagline = ' check out on ';
|
||||||
|
|
||||||
if (!($jsonTxt = file_get_contents($feed_url))) {
|
if (!($jsonTxt = file_get_contents($feed_url))) {
|
||||||
die('Error loading the feed url');
|
exit('Error loading the feed url');
|
||||||
}
|
}
|
||||||
|
|
||||||
$json = json_decode($jsonTxt, true);
|
$json = json_decode($jsonTxt, true);
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
array_push($statuses, $post);
|
array_push($statuses, $post);
|
||||||
if (!$first_article) {
|
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);
|
fwrite($myfile, $ts);
|
||||||
fclose($myfile);
|
fclose($myfile);
|
||||||
$first_article = true;
|
$first_article = true;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
$file = 'data.txt';
|
$file = 'data.txt';
|
||||||
|
|
||||||
if (!($rss = simplexml_load_file($feed_url))) {
|
if (!($rss = simplexml_load_file($feed_url))) {
|
||||||
die('Error loading the feed url');
|
exit('Error loading the feed url');
|
||||||
}
|
}
|
||||||
|
|
||||||
$first_article = false;
|
$first_article = false;
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
array_push($statuses, $post);
|
array_push($statuses, $post);
|
||||||
if (!$first_article) {
|
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);
|
fwrite($myfile, $ts);
|
||||||
fclose($myfile);
|
fclose($myfile);
|
||||||
$first_article = true;
|
$first_article = true;
|
||||||
|
|
|
@ -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);
|
Loading…
Reference in New Issue