2017-09-04 21:09:59 +00:00
|
|
|
package telegraph
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
|
|
|
|
json "github.com/pquerna/ffjson/ffjson"
|
|
|
|
http "github.com/valyala/fasthttp"
|
|
|
|
)
|
|
|
|
|
|
|
|
// GetPage get a Telegraph page. Returns a Page object on success.
|
|
|
|
func GetPage(path string, returnContent bool) (*Page, error) {
|
2017-12-13 10:08:43 +00:00
|
|
|
args := http.AcquireArgs()
|
2017-09-04 21:09:59 +00:00
|
|
|
|
|
|
|
// If true, content field will be returned in Page object.
|
|
|
|
args.Add("return_content", strconv.FormatBool(returnContent))
|
|
|
|
|
2017-12-13 10:04:05 +00:00
|
|
|
body, err := request("getPage", path, args)
|
2017-09-04 21:09:59 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
var resp Page
|
|
|
|
err = json.Unmarshal(*body.Result, &resp)
|
|
|
|
|
|
|
|
return &resp, err
|
|
|
|
}
|