Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
yyoshiki41 committed Nov 20, 2016
1 parent b5c1326 commit 17c8cfc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,42 @@ authToken, err := client.AuthorizeToken(context.Background(), authKeyPath)
if err != nil {
log.Fatal(err)
}
fmt.Println(authToken)
```

#### Premium member (Enable to use the [area free](http://radiko.jp/rg/premium/).)

Step 1,2 are the same as above.

```go
// 3. Create a new Client.
client, err := radiko.New("")
if err != nil {
panic(err)
}

// 4. Login as the premium member
// After client.Login() has succeeded,
// the client has the valid cookie internally.
ctx := context.Background()
login, err := client.Login(ctx, "example@mail.com", "example_password")
if err != nil {
log.Fatal(err)
}
if login.StatusCode() != 200 {
log.Fatalf("Failed to login premium member.\nInvalid status code: %d",
login.StatusCode())
}

// 5. Enables and sets the auth_token.
// After client.AuthorizeToken() has succeeded,
// the client has the enabled auth_token internally.
authToken, err := client.AuthorizeToken(context.Background(), authKeyPath)
if err != nil {
log.Fatal(err)
}
```


### ■ Use your authentication token

```go
Expand Down
2 changes: 1 addition & 1 deletion login.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
)

// Login returns Statuser that has StatusCode method.
// Login returns the Statuser that has StatusCode method.
func (c *Client) Login(ctx context.Context, mail, password string) (Statuser, error) {
err := c.login(ctx, mail, password)
if err != nil {
Expand Down

0 comments on commit 17c8cfc

Please sign in to comment.