2017-04-13 16:48:45 +09:00
|
|
|
# go-mastodon
|
|
|
|
|
|
2017-04-15 04:15:25 +09:00
|
|
|
[](https://travis-ci.org/mattn/go-mastodon)
|
2017-04-14 17:50:12 +09:00
|
|
|
[](https://coveralls.io/github/mattn/go-mastodon?branch=master)
|
2017-04-14 17:15:42 +09:00
|
|
|
[](http://godoc.org/github.com/mattn/go-mastodon)
|
|
|
|
|
[](https://goreportcard.com/report/github.com/mattn/go-mastodon)
|
2017-04-13 16:48:45 +09:00
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
2017-04-27 12:03:11 +09:00
|
|
|
### Application
|
|
|
|
|
|
2017-04-13 16:48:45 +09:00
|
|
|
```go
|
2017-04-27 01:46:18 +09:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"fmt"
|
2017-04-27 12:03:11 +09:00
|
|
|
"log"
|
|
|
|
|
|
2017-04-27 01:46:18 +09:00
|
|
|
"github.com/mattn/go-mastodon"
|
2017-04-27 12:03:11 +09:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
app, err := mastodon.RegisterApp(context.Background(), &mastodon.AppConfig{
|
|
|
|
|
Server: "https://mstdn.jp",
|
|
|
|
|
ClientName: "client-name",
|
|
|
|
|
Scopes: "read write follow",
|
|
|
|
|
Website: "https://github.com/mattn/go-mastodon",
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
fmt.Printf("client-id : %s\n", app.ClientID)
|
|
|
|
|
fmt.Printf("client-secret: %s\n", app.ClientSecret)
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Client
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"fmt"
|
2017-04-27 01:46:18 +09:00
|
|
|
"log"
|
2017-04-27 12:03:11 +09:00
|
|
|
|
|
|
|
|
"github.com/mattn/go-mastodon"
|
2017-04-27 01:46:18 +09:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
c := mastodon.NewClient(&mastodon.Config{
|
|
|
|
|
Server: "https://mstdn.jp",
|
|
|
|
|
ClientID: "client-id",
|
|
|
|
|
ClientSecret: "client-secret",
|
|
|
|
|
})
|
|
|
|
|
err := c.Authenticate(context.Background(), "your-email", "your-password")
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
}
|
2017-05-08 23:36:56 +09:00
|
|
|
timeline, err := c.GetTimelineHome(context.Background(), nil)
|
2017-04-27 01:46:18 +09:00
|
|
|
if err != nil {
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
for i := len(timeline) - 1; i >= 0; i-- {
|
|
|
|
|
fmt.Println(timeline[i])
|
|
|
|
|
}
|
2017-04-13 16:48:45 +09:00
|
|
|
}
|
|
|
|
|
```
|
2017-04-27 12:03:11 +09:00
|
|
|
|
2017-04-15 00:37:27 +09:00
|
|
|
## Status of implementations
|
|
|
|
|
|
|
|
|
|
* [x] GET /api/v1/accounts/:id
|
|
|
|
|
* [x] GET /api/v1/accounts/verify_credentials
|
2017-04-16 21:01:46 +09:00
|
|
|
* [x] PATCH /api/v1/accounts/update_credentials
|
2017-04-15 00:37:27 +09:00
|
|
|
* [x] GET /api/v1/accounts/:id/followers
|
|
|
|
|
* [x] GET /api/v1/accounts/:id/following
|
2017-04-16 21:42:54 +09:00
|
|
|
* [x] GET /api/v1/accounts/:id/statuses
|
2017-04-15 00:37:27 +09:00
|
|
|
* [x] POST /api/v1/accounts/:id/follow
|
|
|
|
|
* [x] POST /api/v1/accounts/:id/unfollow
|
|
|
|
|
* [x] GET /api/v1/accounts/:id/block
|
|
|
|
|
* [x] GET /api/v1/accounts/:id/unblock
|
|
|
|
|
* [x] GET /api/v1/accounts/:id/mute
|
|
|
|
|
* [x] GET /api/v1/accounts/:id/unmute
|
|
|
|
|
* [x] GET /api/v1/accounts/relationships
|
|
|
|
|
* [x] GET /api/v1/accounts/search
|
|
|
|
|
* [x] POST /api/v1/apps
|
2017-04-15 16:28:18 +09:00
|
|
|
* [x] GET /api/v1/blocks
|
|
|
|
|
* [x] GET /api/v1/favourites
|
|
|
|
|
* [x] GET /api/v1/follow_requests
|
2017-04-17 01:37:29 +09:00
|
|
|
* [x] POST /api/v1/follow_requests/:id/authorize
|
|
|
|
|
* [x] POST /api/v1/follow_requests/:id/reject
|
2017-04-15 00:37:27 +09:00
|
|
|
* [x] POST /api/v1/follows
|
|
|
|
|
* [x] GET /api/v1/instance
|
2017-04-17 13:56:35 +09:00
|
|
|
* [x] POST /api/v1/media
|
2017-04-17 13:00:53 +09:00
|
|
|
* [x] GET /api/v1/mutes
|
2017-04-15 00:37:27 +09:00
|
|
|
* [x] GET /api/v1/notifications
|
|
|
|
|
* [x] GET /api/v1/notifications/:id
|
|
|
|
|
* [x] POST /api/v1/notifications/clear
|
2017-04-17 04:51:16 +09:00
|
|
|
* [x] GET /api/v1/reports
|
|
|
|
|
* [x] POST /api/v1/reports
|
2017-04-16 21:47:15 +09:00
|
|
|
* [x] GET /api/v1/search
|
2017-04-15 00:37:27 +09:00
|
|
|
* [x] GET /api/v1/statuses/:id
|
|
|
|
|
* [x] GET /api/v1/statuses/:id/context
|
|
|
|
|
* [x] GET /api/v1/statuses/:id/card
|
2017-04-16 21:01:46 +09:00
|
|
|
* [x] GET /api/v1/statuses/:id/reblogged_by
|
|
|
|
|
* [x] GET /api/v1/statuses/:id/favourited_by
|
|
|
|
|
* [x] POST /api/v1/statuses
|
2017-04-15 21:07:11 +09:00
|
|
|
* [x] DELETE /api/v1/statuses/:id
|
2017-04-16 21:01:46 +09:00
|
|
|
* [x] POST /api/v1/statuses/:id/reblog
|
|
|
|
|
* [x] POST /api/v1/statuses/:id/unreblog
|
|
|
|
|
* [x] POST /api/v1/statuses/:id/favourite
|
|
|
|
|
* [x] POST /api/v1/statuses/:id/unfavourite
|
2017-04-15 00:37:27 +09:00
|
|
|
* [x] GET /api/v1/timelines/home
|
2017-04-15 16:28:18 +09:00
|
|
|
* [x] GET /api/v1/timelines/public
|
2017-04-15 21:02:55 +09:00
|
|
|
* [x] GET /api/v1/timelines/tag/:hashtag
|
2017-04-13 16:48:45 +09:00
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
$ go get github.com/mattn/go-mastodon
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
|
|
|
|
MIT
|
|
|
|
|
|
|
|
|
|
## Author
|
|
|
|
|
|
|
|
|
|
Yasuhiro Matsumoto (a.k.a. mattn)
|