本文整理匯總了Golang中github.com/kurrik/twittergo.APIResponse.MediaRateLimitRemaining方法的典型用法代碼示例。如果您正苦於以下問題:Golang APIResponse.MediaRateLimitRemaining方法的具體用法?Golang APIResponse.MediaRateLimitRemaining怎麽用?Golang APIResponse.MediaRateLimitRemaining使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/kurrik/twittergo.APIResponse
的用法示例。
在下文中一共展示了APIResponse.MediaRateLimitRemaining方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
var (
err error
client *twittergo.Client
req *http.Request
resp *twittergo.APIResponse
tweet *twittergo.Tweet
)
client, err = LoadCredentials()
if err != nil {
fmt.Printf("Could not parse CREDENTIALS file: %v\n", err)
os.Exit(1)
}
body, header, err := GetBody()
if err != nil {
fmt.Printf("Problem loading body: %v\n", err)
os.Exit(1)
}
endpoint := "/1.1/statuses/update_with_media.json"
req, err = http.NewRequest("POST", endpoint, body)
if err != nil {
fmt.Printf("Could not parse request: %v\n", err)
os.Exit(1)
}
req.Header.Set("Content-Type", header)
resp, err = client.SendRequest(req)
if err != nil {
fmt.Printf("Could not send request: %v\n", err)
os.Exit(1)
}
tweet = &twittergo.Tweet{}
err = resp.Parse(tweet)
if err != nil {
fmt.Printf("Problem parsing response: %v\n", err)
os.Exit(1)
}
fmt.Printf("ID: %v\n", tweet.Id())
fmt.Printf("Tweet: %v\n", tweet.Text())
fmt.Printf("User: %v\n", tweet.User().Name())
if resp.HasRateLimit() {
fmt.Printf("Rate limit: %v\n", resp.RateLimit())
fmt.Printf("Rate limit remaining: %v\n", resp.RateLimitRemaining())
fmt.Printf("Rate limit reset: %v\n", resp.RateLimitReset())
} else {
fmt.Printf("Could not parse rate limit from response.\n")
}
if resp.HasMediaRateLimit() {
fmt.Printf("Media Rate limit: %v\n", resp.MediaRateLimit())
fmt.Printf("Media Rate limit remaining: %v\n", resp.MediaRateLimitRemaining())
fmt.Printf("Media Rate limit reset: %v\n", resp.MediaRateLimitReset())
} else {
fmt.Printf("Could not parse media rate limit from response.\n")
}
}