Advertisement
BlakeMS

Untitled

Oct 22nd, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getMoreTweets(id, bigData, a, b, res, ssname) {
  2.     if ( (moment.tz(Date.parse(bigData[bigData.length-1].created_at), "Pacific/Auckland").format('YYYY-MM-DD')) == todayDate ) {
  3.         var todayDate = moment.tz(Date.now(), "Pacific/Auckland").format('YYYY-MM-DD');
  4.         if (ssname) {
  5.                 oauth.get(
  6.                   "https://api.twitter.com/1.1/statuses/user_timeline.json?user_id="+id+"&count=200&trim_user=1&max_id="+bigData[bigData.length-1].id,
  7.                   a, b,
  8.                   function(error, data) {
  9.                         if(error) {
  10.                                 console.log(require('sys').inspect(error));
  11.                                 res.status(409).send('Error');
  12.                         }
  13.                         else {
  14.                                 if (data) {
  15.                                         var tempData = JSON.parse(data);
  16.                                         tempData.shift();
  17.                                         bigData = bigData.concat(tempData);
  18.                                         console.log('got more tweets - '+ssname);
  19.                                         if ( (moment.tz(Date.parse(bigData[bigData.length-1].created_at), "Pacific/Auckland").format('YYYY-MM-DD')) == todayDate ) {
  20.                                                 getMoreTweets(id, bigData, a, b, res);
  21.                                         }
  22.                                                
  23.                                         }
  24.                                 }
  25.                         }
  26.                   }
  27.                 );
  28.         }
  29.     }
  30. }
  31.  
  32. getMoreTweets(id,bigData,a,b,res,ssname);
  33.  
  34. if ((moment.tz(Date.parse(bigData[0].created_at), "Pacific/Auckland").format('YYYY-MM-DD')) != todayDate) {
  35.     bigData = 0;
  36. }
  37. else {
  38.     while ( (moment.tz(Date.parse(bigData[bigData.length-1].created_at), "Pacific/Auckland").format('YYYY-MM-DD')) != todayDate ) {
  39.     bigData.pop();
  40.     }
  41. }
  42. res.json(bigData);
  43. todayDate = null;
  44. bigData = null;
  45. tempData = null;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement