-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
38 changed files
with
1,027 additions
and
2,265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
node_modules | ||
queryCMD | ||
data/*.JSON | ||
.env | ||
data/*.JSON |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
var Promise = require('promise'); | ||
var config = require('../config'); | ||
var FB = require('fb'); | ||
FB.options({version:'v2.8'}); | ||
FB.setAccessToken(config.fb.access_token); //token need to renew every 60 days! | ||
|
||
function search(args,type){ | ||
return new Promise((resolve,reject) => { | ||
FB.api('search?q=' + args['q'] + '&type=' + type,(fb)=>{ | ||
if(!fb || fb.error) { | ||
reject(fb.error); | ||
}else{ | ||
//console.log(fb.data); | ||
resolve(fb.data); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
function getField(id,field){ | ||
// bad idea to query fields... rethink later!!!!!!!!!!! | ||
return new Promise((resolve,reject) =>{ | ||
FB.api(id['id'],{fields:field},(fb) =>{ | ||
if(!fb || fb.error) { | ||
reject(fb.error); | ||
}else{ | ||
//console.log(field,fb); | ||
resolve(fb[field]); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
function getEdge(id,edge){ | ||
//rethink later!!!!!!!!!!! | ||
return new Promise((resolve,reject) =>{ | ||
FB.api(id['id'] + "/" + edge ,(fb) =>{ | ||
if(!fb || fb.error) { | ||
reject(fb.error); | ||
}else{ | ||
//console.log(edge,fb); | ||
resolve(fb.data); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
module.exports = { | ||
search, | ||
getField, | ||
getEdge | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
var Promise = require('promise'); | ||
var request = require('request'); | ||
|
||
function mediaWiki(args, fname){ | ||
return new Promise((resolve, reject) =>{ | ||
console.log("In MediaWiki API, switch functionality now"); | ||
console.log(fname); | ||
var queryUrl = 'https://en.wikipedia.org/w/api.php?'; | ||
switch(fname){ | ||
case "wikiPageContent": | ||
queryUrl = wikiPageContent(args, queryUrl); | ||
break; | ||
} | ||
console.log(queryUrl); | ||
|
||
var options = { | ||
method: 'GET', | ||
uri: queryUrl, | ||
}; | ||
|
||
request(options, function(error, response){ | ||
if(error) { | ||
console.log("Reuqest error") | ||
reject(error); | ||
} | ||
|
||
if(response) { | ||
console.log("send response data back") | ||
resolve(JSON.parse(response.body)); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
function wikiPageContent(args, queryUrl){ | ||
queryUrl += "action=query&prop=revisions&rvprop=content&format=json"; | ||
for(var key in args){ | ||
queryUrl += '&' + key + '=' + encodeURIComponent(args[key]); | ||
} | ||
console.log(queryUrl); | ||
return queryUrl | ||
} | ||
|
||
module.exports = { | ||
mediaWiki | ||
} | ||
|
||
var Promise = require('promise'); | ||
var request = require('request'); | ||
|
||
function mediaWiki(args, fname){ | ||
return new Promise((resolve, reject) =>{ | ||
console.log("In MediaWiki API, switch functionality now"); | ||
console.log(fname); | ||
var queryUrl = 'https://en.wikipedia.org/w/api.php?'; | ||
switch(fname){ | ||
case "wikiPageContent": | ||
queryUrl = wikiPageContent(args, queryUrl); | ||
break; | ||
} | ||
console.log(queryUrl); | ||
|
||
var options = { | ||
method: 'GET', | ||
uri: queryUrl, | ||
}; | ||
|
||
request(options, function(error, response){ | ||
if(error) { | ||
console.log("Reuqest error") | ||
reject(error); | ||
} | ||
|
||
if(response) { | ||
console.log("send response data back") | ||
console.log(response.body) | ||
resolve(JSON.parse(response.body)); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
function wikiPageContent(args, queryUrl){ | ||
queryUrl += "action=query&prop=revisions&rvprop=content&format=json"; | ||
for(var key in args){ | ||
queryUrl += '&' + key + '=' + encodeURIComponent(args[key]); | ||
} | ||
console.log(queryUrl); | ||
return queryUrl | ||
} | ||
|
||
module.exports = { | ||
mediaWiki | ||
} |
Oops, something went wrong.