Skip to content

Commit

Permalink
Revert "Trying to merge now"
Browse files Browse the repository at this point in the history
This reverts commit 89be404.
  • Loading branch information
ghostlilunan committed Apr 28, 2017
1 parent e46e5be commit 84f21e6
Show file tree
Hide file tree
Showing 38 changed files with 1,027 additions and 2,265 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
node_modules
queryCMD
data/*.JSON
.env
data/*.JSON
52 changes: 52 additions & 0 deletions API/fbAPI.js
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
};
203 changes: 0 additions & 203 deletions API/instagramAPI.js

This file was deleted.

94 changes: 47 additions & 47 deletions API/mediaWikiAPI.js
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
}
Loading

0 comments on commit 84f21e6

Please sign in to comment.