feed()

in SampleIntegrations/SampleBots/NodeJS/FeedPoster/clock.js [28:59]


    feed(FEED_URL, function(err, articles) {
        if (err) throw err;

        for ( let i in articles ) {
			// Only ever post one article per cycle
            if ( i > 0 ) return;

            var article = articles[i];
			// Only post articles published since last check
            if (article.published < last_check) {
                console.log('No new posts since ' + last_check);
                return;
            }

            graphapi({
                method: 'POST',
                url: '/' + TARGET_GROUP + '/feed',
                qs: {
                    'message': article.title,
                    'link': article.link
                }
            },function(error,response,body) {
                if(error) {
                    console.error(error);
                } else {
                    var post_id = JSON.parse(body).id;
                    console.log('Published "' + article.title + '": ' + post_id);
                    last_check = Date.now();
                }
            });
        }
    });