Merge pull request #47 from 178inaba/readme_small_fix

Fix document
pull/49/head
mattn 2017-04-27 15:00:57 +09:00 committed by GitHub
commit b8fe5a0533
3 changed files with 94 additions and 9 deletions

View File

@ -7,14 +7,45 @@
## Usage
### Application
```go
package main
import (
"context"
"fmt"
"github.com/mattn/go-mastodon"
"log"
"github.com/mattn/go-mastodon"
)
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"
"log"
"github.com/mattn/go-mastodon"
)
func main() {
@ -36,6 +67,7 @@ func main() {
}
}
```
## Status of implementations
* [x] GET /api/v1/accounts/:id

View File

@ -15,14 +15,25 @@ VERSION:
0.0.1
COMMANDS:
toot post toot
stream stream statuses
timeline show timeline
help, h Shows a list of commands or help for one command
toot post toot
stream stream statuses
timeline show timeline
notification show notification
instance show instance information
account show account information
search search content
follow follow account
followers show followers
upload upload file
delete delete status
init initialize profile
mikami search mikami
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--help, -h show help
--version, -v print the version
--profile value profile name
--help, -h show help
--version, -v print the version
```
## Installation

42
example_test.go 100644
View File

@ -0,0 +1,42 @@
package mastodon_test
import (
"context"
"fmt"
"log"
"github.com/mattn/go-mastodon"
)
func ExampleRegisterApp() {
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)
}
func ExampleClient() {
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)
}
timeline, err := c.GetTimelineHome(context.Background())
if err != nil {
log.Fatal(err)
}
for i := len(timeline) - 1; i >= 0; i-- {
fmt.Println(timeline[i])
}
}