예제 #1
0
파일: feed.go 프로젝트: yukihir0/hbapi
func main() {
	user := "******"
	params := hbapi.NewFeedParams(user)
	//params.SetUser("yukihir0")
	//params.SetPage(1)
	//params.SetTag("golang")
	params.SetDate(time.Date(2015, 7, 29, 0, 0, 0, 0, time.UTC))
	//params.SetURL("http://d.hatena.ne.jp")

	feed, err := hbapi.GetFeed(params)
	if err != nil {
		panic(err)
	}

	for _, item := range feed.Items {
		fmt.Println(item.Title)
	}
}
예제 #2
0
파일: http_api.go 프로젝트: yukihir0/hbn
func (api HttpAPI) RequestBookmarks(user string, page int) []Bookmark {
	params := hbapi.NewFeedParams(user)
	params.SetPage(page)
	feed, err := hbapi.GetFeed(params)
	if err != nil {
		return []Bookmark{}
	}

	bookmarks := []Bookmark{}
	for _, item := range feed.Items {
		bookmarks = append(bookmarks, Bookmark{
			Title: item.Title,
			URL:   item.Link,
			Count: item.BookmarkCount,
		})
	}

	return bookmarks
}
예제 #3
0
파일: http_api.go 프로젝트: yukihir0/hbcf
func (api HttpAPI) RequestUserItems(user User, page int) []UserItem {
	params := hbapi.NewFeedParams(user.Name)
	params.SetPage(page)
	feed, err := hbapi.GetFeed(params)
	if err != nil {
		return []UserItem{UserItem{
			User: user,
			Item: Item{},
		}}
	}

	userItems := []UserItem{}
	for _, item := range feed.Items {
		userItems = append(userItems, UserItem{
			User: user,
			Item: Item{
				Title:         item.Title,
				URL:           item.Link,
				BookmarkCount: item.BookmarkCount,
			}})
	}

	return userItems
}