Ejemplo n.º 1
0
func main() {
	//	bq := baidu.NewBcms(bcmsq, access_token, client_id, client_secret)
	bq := baidu.NewBcmsProxy("http://iweizhi2.duapp.com/pop.json")
	var v pubsub.PubsubMessage
	err := bq.FetchOneAsJson(&v)
	fmt.Println(v, err)
}
Ejemplo n.º 2
0
func feedentries_updated() (ReadSource, []ReadEntry, error) {
	bcms := baidu.NewBcmsProxy(baiduq)
	var v pubsub.PubsubMessage
	err := bcms.FetchOneAsJson(&v)
	if err != nil {
		return ReadSource{}, nil, err
	}
	if (v.Status.StatusCode != 200 && v.Status.StatusCode != 0) || v.Status.Feed == "" {
		return ReadSource{}, nil, new_backenderror(v.Status.StatusCode, v.Status.StatusReason)
	}
	fs := ReadSource{
		FeedSource: feed.FeedSource{
			Name:        v.Title,
			Uri:         v.Status.Feed,
			Description: v.Subtitle,
			Period:      v.Status.Period / 60,
			Update:      int64(v.Updated),
		},
		LastTouch:  int64(unixtime.TimeNow()),
		NextTouch:  int64(unixtime.Time(v.Status.Period) + unixtime.TimeNow()),
		LastUpdate: int64(unixtime.TimeNow()),
	}
	if fs.Period == 0 {
		fs.Period = 120 // minutes
	}
	fes := make([]ReadEntry, len(v.Items))
	for idx, i := range v.Items {
		fes[idx] = ReadEntry{
			FeedEntry: feed.FeedEntry{
				Uri:     i.Uri,
				Title:   i.Title,
				PubDate: int64(i.Published),
				Summary: i.Summary,
				Content: i.Content,
				Tags:    i.Categories,
			},
		}
		feedentry_init_from_standardlinks(i.StandardLinks, fes[idx])
		if fes[idx].Uri == "" {
			feedentry_init_from_links(i.Links, fes[idx])
		}
	}
	if err == nil {
		fes = readentry_filter(fes)
		fo := new_feedsource_operator()
		// ignore touch error, because, source may not be subscribed
		fo.touch(fs.Uri, int64(fs.LastTouch), int64(fs.NextTouch), fs.Period)
	}
	log.Println("updated", fs.Name, fs.Update)
	return fs, fes, err
}