telegraph/create_account.go

28 lines
833 B
Go
Raw Normal View History

2017-09-04 21:09:59 +00:00
package telegraph
import (
http "github.com/valyala/fasthttp"
)
2018-07-27 11:51:14 +00:00
// CreateAccount create a new Telegraph account. Most users only need one
// account, but this can be useful for channel administrators who would like to
// keep individual author names and profile links for each of their channels. On
// success, returns an Account object with the regular fields and an additional
// access_token field.
2019-07-24 08:03:29 +00:00
func CreateAccount(account Account) (*Account, error) {
args := http.AcquireArgs()
2018-07-27 11:51:14 +00:00
defer http.ReleaseArgs(args)
2017-09-04 21:09:59 +00:00
args.Add("short_name", account.ShortName) // required
args.Add("author_name", account.AuthorName)
args.Add("author_url", account.AuthorURL)
2019-07-24 08:03:29 +00:00
data, err := makeRequest("createAccount", args)
2017-09-04 21:09:59 +00:00
if err != nil {
2019-07-24 08:03:29 +00:00
return nil, err
2017-09-04 21:09:59 +00:00
}
2019-07-24 08:03:29 +00:00
var result Account
err = parser.Unmarshal(data, &result)
return &result, err
2017-09-04 21:09:59 +00:00
}