https://github.com/peter-mount/go-mastodon
A simple Mastodon client for golang
https://github.com/peter-mount/go-mastodon
Last synced: 5 months ago
JSON representation
A simple Mastodon client for golang
- Host: GitHub
- URL: https://github.com/peter-mount/go-mastodon
- Owner: peter-mount
- License: apache-2.0
- Created: 2022-11-23T20:27:11.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-28T22:04:52.000Z (over 3 years ago)
- Last Synced: 2024-12-06T21:38:22.437Z (over 1 year ago)
- Language: Go
- Size: 14.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mastodon client in go
This is a very basic mastodon client for use with bots.
I needed something for my [weather station bot](https://area51.social/@me15weather)
and this library is the result.
If a feature is not listed below then please raise an issue as I will be expanding
this library as and when I need features for various projects.
## Features
* Verify AccessToken is valid
* Submit plain text post to mastodon server
* Retrieve a timeline from the server
### To be implemented
* Upload media to attaching to posts (i.e. images)
## Example
config := mastodon.Config{
Server: "https://example.com/",
AccessToken: "tokenfromserver",
}
client := config.Client()
// Verify AccessToken is valid
_, err := client.VerifyCredentials()
if err != nil {
panic(err)
}
// Post to the server
status := PostStatus{Text: "This post is from golang"}
_, error := client.Post(status)
if err != nil {
panic(err)
}
You can get the access token by logging into your Mastodon account, going into settings,
Development and add a new application which will give you a client key, secret and access token.
You only need the latter for this library to work.