Skip to content

Instantly share code, notes, and snippets.

@odeke-em
Created May 8, 2017 07:39
Show Gist options
  • Save odeke-em/c7ac331aae72784e2f225b9a6d4208c4 to your computer and use it in GitHub Desktop.
Save odeke-em/c7ac331aae72784e2f225b9a6d4208c4 to your computer and use it in GitHub Desktop.
Demo for Dre
package main
import (
"fmt"
"log"
"github.com/orijtech/500px/v1"
)
func main() {
client, err := px500.NewClient()
if err != nil {
log.Fatal(err)
}
preq := &px500.PhotoRequest{
LimitPerPage: 20,
MaxPageNumber: 30,
Feature: px500.FeaturePopular,
}
pagesChan, cancelFn, err := client.ListPhotos(preq)
if err != nil {
log.Fatal(err)
}
count := uint64(0)
for page := range pagesChan {
fmt.Printf("Page: #%d\n\n", page.PageNumber)
for i, photo := range page.Photos {
count += 1
fmt.Printf("#%d: %#v\n\n", i, photo)
}
if count >= 13 {
cancelFn()
}
fmt.Printf("\n\n")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment