本文整理匯總了TypeScript中twitter.get函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript get函數的具體用法?TypeScript get怎麽用?TypeScript get使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了get函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getTrends
function getTrends(woeid, callback) {
console.log('trend request for', woeid)
var cacheKey = 'trend_' + woeid;
var cachedTrends = myCache.get(cacheKey);
if (!cachedTrends[cacheKey]) {
console.log('refreshing cache trends');
tApi.get('/trends/place', {
id: woeid
}, function (err, data) {
if (err) {
console.log(err);
throw err;
}
myCache.set(cacheKey, data[0]);
callback(data[0].trends)
});
} else {
console.log('returning trends from cache')
callback(cachedTrends[cacheKey].trends);
}
}
示例2: rej
var p = new Promise<any>((res, rej) => {
tApi.get('/search/tweets', {
q: subject,
geocode: lat + ',' + long + ',1km'
}, (err, data) => {
if (err) {
console.log(err);
rej(err);
}
res(data);
});
});
示例3: function
app.get('/api/twitter/', (req, res) => {
if (cache) {
res.jsonp(cache);
return;
}
client.get('statuses/home_timeline', function (error, tweets) {
if (error) throw error;
console.log(tweets); // The favorites.
//console.log(response); // Raw response object.
cache = tweets;
res.jsonp(cache);
});
});
示例4: getClosest
function getClosest(lat, long, callback) {
tApi.get('/trends/closest', {
lat: lat,
long: long
},
function (err, data) {
if (err) {
console.log(err)
if (err.code != 88) {
throw err;
} else {
callback(null);
}
}
callback(data);
});
}
示例5: function
twit.get('/statuses/show/'+targetTweetId+'.json',{include_my_retweet: true}, function(targetData:any){
if(isError(targetData)) {
return;
}
console.log(targetData);
if(targetData.current_user_retweet) {
// RT済みならばRTを取得
var RetweetedId:string = targetData.current_user_retweet.id_str;
twit.get('/statuses/show/'+RetweetedId+'.json',{}, function(retweetedData:any){
console.log('Retweeted');
console.log(retweetedData);
// RT時間取得
var RetweetTime:Date = new Date(retweetedData.created_at);
// インターバル設定
var interval:number = 5 /* min */ * 60 * 1000;
// RTからの経過時間取得
var now:Date = new Date();
var elapsed:number = now.getTime() - RetweetTime.getTime();
// インターバルを過ぎているならばRTを削除
if(elapsed > interval) {
twit.post('/statuses/destroy/'+RetweetedId+'.json', {}, function(destroiedData:any){
console.log(destroiedData);
});
}
});
} else {
// RT
twit.post('/statuses/retweet/'+targetTweetId+'.json', {}, function (data:any) {
if(isError(data)) {
return;
}
console.log(data);
});
}
});
示例6: function
router.get('/tweets', (req: Request, res: Response, next: Function) => {
twitter.get('search/tweets', {q: 'javascript', lang: 'es'}, function (error: Error,tweets: any,response: Response){
if(error) throw error;
res.send("<pre>"+JSON.stringify(tweets,null,2)+"</pre>");
})
});