-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
120 lines (105 loc) · 2.98 KB
/
index.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
var http = require('http'),
fs = require('fs'),
path = require('path'),
url = require('url'),
Twitter = require('twitter'),
events = require('events'),
ig = require('instagram-node').instagram(),
tweets,
tweetsArray = [],
keyChain = require('./key.js'),
mongojs = require('mongojs');
function requestHandler(request, response){
var reqName = path.basename(request.url) || 'index.html';
if (reqName === 'ourtweets') {
response.writeHead(200, {'content-Type': 'application/javascript'});
response.write(tweetsArray);
response.end();
} else {
fs.readFile(__dirname + '/' + 'index.html', function(err, data){
if (!err) {
response.writeHead(200, {'Content-Type': 'text/html'});
response.write(data);
//instagram
// response.write(JSON.stringify(medias));
response.end();
} else {
response.writeHead(404, {'Content-Type': 'text/html'});
response.end('<h1>Error</h1>');
}
});
}
}
http.createServer(requestHandler).listen(1337);
console.log('Server up and running');
var twitterObj = new Twitter({
consumer_key: keyChain.consumer_key,
consumer_secret: keyChain.consumer_secret,
access_token_key: keyChain.access_token_key,
access_token_secret: keyChain.access_token_secret
}); //Rory's Twitter keys
//twitter
function catchFish(){
var type = 'search/tweets';
var params = {q: 'fish'};
twitterObj.get(type, params, fishGutter);
}
function fishGutter(error, data, response){
for(var i = 0; i < data.statuses.length; i++) {
console.log(data.statuses[i].text);
tweets = data.statuses[i].text;
tweetsArray.push(tweets);
}
}
//instagram
ig.use({
client_id: keyChain.client_id,
client_secret: keyChain.client_secret
});
ig.tag_media_recent('coding', function(err, medias, pagination, remaining, limit) {
for (var i = 0; i < 10; i++) {
console.log(medias[i].images.standard_resolution.url);
}
});
//Database ======================================================//
//var db = ('mongodb://lottie-em:arcjrules@ds039281.mongolab.com:39281/arcj', ["tweetsImages", "instaImages"]);
//
//twitObjs = {
// name: searchTerm.toLowerCase,
// expiryDate:
// twArray: []
//}
// {
// name: "charlotte",
// url: "www.yolo.jpeg",
// post_link: "www.yolo.com/post1",
// hashtag: "yolo"
// }
//
//searchTerm = 'people';
//urlify
//
//searchedThings = ["confectionary", "articleofclothing", "cake", "pastries", "departmentstores"];
//
//function prevSearches(searching) {
// if(searchedThings.indexOf(searching.toLowerCase === -1){
// searchedThings.push(searching.toLowerCase);
// } else {
// databaseQuery(searchTerm.toLowerCase);
// }
//function databaseQuery(findme){
// db.twitterImages.find({name: findme}, function(error, twitterImages){
// if(err){
// throw err;
// } else {
// twitterImages.forEach(function)
// }
// })
//}
//
//}
//
//
//db.tweetImages.
//
//