Exemple #1
0
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)
	}
}
Exemple #2
0
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
}
Exemple #3
0
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
}