@@ -2,22 +2,29 @@ package main
2
2
3
3
import (
4
4
"fmt"
5
+ "os"
5
6
"strconv"
6
7
7
8
listennotes "github.com/ListenNotes/podcast-api-go"
8
9
)
9
10
10
11
func main () {
11
- client := listennotes .NewClient ("" )
12
+ apiKey := os .Getenv ("LISTEN_API_KEY" )
13
+
14
+ client := listennotes .NewClient (apiKey )
12
15
13
16
// The test data will return the same page each time, but this is an example of getting the next_offset out fo the resulting payload
14
17
nextOffset := fetchAndOutputPage (client , 0 )
15
18
fetchAndOutputPage (client , nextOffset )
16
19
17
20
// You can get the output json easily as well:
18
21
fmt .Printf ("\n Regions:\n " )
19
- regions , _ := client .FetchPodcastRegions (nil )
20
- fmt .Println (regions .ToJSON ())
22
+ regions , err := client .FetchPodcastRegions (nil )
23
+ if err != nil {
24
+ fmt .Printf ("Failed reading regions: %s\n " , err )
25
+ } else {
26
+ fmt .Println (regions .ToJSON ())
27
+ }
21
28
}
22
29
23
30
func fetchAndOutputPage (client listennotes.HTTPClient , offset int ) int {
@@ -48,8 +55,8 @@ func fetchAndOutputPage(client listennotes.HTTPClient, offset int) int {
48
55
return nextOffset
49
56
}
50
57
51
- // searchResults, _ := client.Search(map[string]string {"q": "star wars"});
58
+ // searchResults, err := client.Search(map[string]string {"q": "star wars"});
52
59
// fmt.Println(searchResults.ToJSON())
53
60
54
- // typeaheadResults, _ := client.Typeahead(map[string]string {"q": "star wars"});
61
+ // typeaheadResults, err := client.Typeahead(map[string]string {"q": "star wars"});
55
62
// fmt.Println(typeaheadResults.ToJSON())
0 commit comments