-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathExample.js
44 lines (36 loc) · 1.26 KB
/
Example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// An example of how to use the UntappdClient.
//
// By Glen R. Goodwin
// twitter: @areinet
// Imports
var UntappdClient = require("./UntappdClient",false);
// Definitions
// Replace this with your CLIENT ID
var clientId = "[ your api key goes here ]";
// Replace this with your CLIENT SECRET
var clientSecret = "[ your client secret goes here ]";
// Set to true if you want to see all sort of nasty output on stdout
var debug = false;
// The user we want to lookup for this example
var data = {};
data.USERNAME = "[ some user name ]";
// Create Client
var untappd = new UntappdClient(debug);
untappd.setClientId(clientId);
untappd.setClientSecret(clientSecret);
// EXAMPLE - List last 25 recent checkins of the given user
untappd.userActivityFeed(function(err,obj){
if (debug) console.log(err,obj);
if (obj && obj.response && obj.response.checkins && obj.response.checkins.items) {
var beers = obj.response.checkins.items.forEach(function(checkin) {
console.log(checkin);
console.log(checkin.user.user_name, "drank", checkin.beer.beer_name);
console.log("by", checkin.brewery.brewery_name);
if (checkin.venue.venue_name)
console.log("at", checkin.venue.venue_name);
console.log("on", checkin.created_at);
});
} else {
console.log(err, obj);
}
}, data);