本文整理汇总了Golang中code/google/com/p/goauth2/oauth.Transport.RoundTrip方法的典型用法代码示例。如果您正苦于以下问题:Golang Transport.RoundTrip方法的具体用法?Golang Transport.RoundTrip怎么用?Golang Transport.RoundTrip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类code/google/com/p/goauth2/oauth.Transport
的用法示例。
在下文中一共展示了Transport.RoundTrip方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: handleTimelineNotification
// handleTimelineNotification processes a timeline notification.
func handleTimelineNotification(c appengine.Context, svc *mirror.Service, not *mirror.Notification, transport *oauth.Transport) error {
for _, ua := range not.UserActions {
if ua.Type != "SHARE" {
c.Infof("I don't know what to do with this notification: %+v", ua)
continue
}
t, err := svc.Timeline.Get(not.ItemId).Do()
if err != nil {
return fmt.Errorf("Unable to retrieve timeline item: %s", err)
}
nt := &mirror.TimelineItem{
Text: fmt.Sprintf("Echoing your shared item: %s", t.Text),
Notification: &mirror.NotificationConfig{Level: "DEFAULT"},
}
tic := svc.Timeline.Insert(nt)
if t.Attachments != nil && len(t.Attachments) > 0 {
a, err := svc.Timeline.Attachments.Get(t.Id, t.Attachments[0].Id).Do()
if err != nil {
return fmt.Errorf("Unable to retrieve attachment metadata: %s", err)
}
req, err := http.NewRequest("GET", a.ContentUrl, nil)
if err != nil {
return fmt.Errorf("Unable to create new HTTP request: %s", err)
}
resp, err := transport.RoundTrip(req)
if err != nil {
return fmt.Errorf("Unable to retrieve attachment content: %s", err)
}
defer resp.Body.Close()
tic.Media(resp.Body)
}
_, err = tic.Do()
if err != nil {
return fmt.Errorf("Unable to insert timeline item: %s", err)
}
}
return nil
}