Skip to content

Commit

Permalink
Revert "Merge branch 'master' into chen-fb-twitter"
Browse files Browse the repository at this point in the history
This reverts commit 9769322.
  • Loading branch information
ghostlilunan committed Apr 28, 2017
1 parent 9769322 commit e46e5be
Show file tree
Hide file tree
Showing 38 changed files with 2,265 additions and 1,027 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
queryCMD
data/*.JSON
data/*.JSON
.env
52 changes: 0 additions & 52 deletions API/fbAPI.js

This file was deleted.

203 changes: 203 additions & 0 deletions API/instagramAPI.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
var request = require('request');
var config = require('../config');

var access_token = config.instagram.access_token_key;

function instagram(args, fname){
return new Promise((resolve, reject) =>{
console.log("In Instagram API, switch functionality now");
console.log(fname);
var queryUrl = "https://api.instagram.com/v1";
switch(fname){
case "usersSelf":
queryUrl = usersSelf(queryUrl);
break;
case "users":
queryUrl = users(args, queryUrl);
break;
case "usersSearch":
queryUrl = usersSearch(args, queryUrl);
break;
case "usersSelfFollows":
queryUrl = usersSelfFollows(queryUrl);
break;
case "usersSelfFollowedBy":
queryUrl = usersSelfFollowedBy(ueryUrl);
break;
case "usersSelfRequestedBy":
queryUrl = usersSelfRequestedBy(queryUrl);
break;
case "usersRelationship":
queryUrl = usersRelationship(args, queryUrl);
break;
case "mediaID":
queryUrl = mediaID(args, queryUrl);
break;
case "mediaShortCode":
queryUrl = mediaShortCode(args, queryUrl);
break;
case "mediaSearch":
queryUrl = mediaSearch(args, queryUrl);
break;
case "comments":
queryUrl = comments(args, queryUrl);
break;
case "likes":
queryUrl = likes(args, queryUrl);
break;
case "tagName":
queryUrl = tagName(args, queryUrl);
break;
case "tagMediaRecent":
queryUrl = tagMediaRecent(args, queryUrl);
break;
case "tagSearch":
queryUrl = tagSearch(args, queryUrl);
break;
case "locationID":
queryUrl = locationID(args, queryUrl);
break;
case "locationMediaRecent":
queryUrl = locationMediaRecent(args, queryUrl);
break;
case "locationSearch":
queryUrl = locationSearch(args, queryUrl);
break;
}

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 usersSelf(queryUrl){
queryUrl += ('/users/self/?access_token=' + access_token);
console.log(queryUrl);
return queryUrl
}

function users(args, queryUrl){
queryUrl += '/users/' + args.user_id + '/?access_token=' + access_token;
console.log(queryUrl);
return queryUrl
}

function usersSearch(args, queryUrl){
queryUrl += '/users/search?access_token=' + access_token;
for(var key in args){
queryUrl += '&' + key + '=' + encodeURIComponent(args[key]);
}
console.log(queryUrl);
return queryUrl
}

function usersSelfFollows(queryUrl){
queryUrl += ('/users/self/follows?access_token=' + access_token);
console.log(queryUrl);
return queryUrl
}

function usersSelfFollowedBy(queryUrl){
queryUrl += ('/users/self/followed-by?access_token=' + access_token);
console.log(queryUrl);
return queryUrl
}

function usersSelfRequestedBy(queryUrl){
queryUrl += ('/users/self/requested-by?access_token=' + access_token);
console.log(queryUrl);
return queryUrl
}

function usersRelationship(args, queryUrl){
queryUrl += ('/users/' + args.user_id + "/relationship?access_token=" + access_token);
console.log(queryUrl);
return queryUrl
}

function mediaID(args, queryUrl){
queryUrl += ('/media/' + args.media_id + "?access_token=" + access_token);
console.log(queryUrl);
return queryUrl
}

function mediaShortCode(args, queryUrl){
queryUrl += ('/media/' + args.shortcode + "/D?access_token=" + access_token);
console.log(queryUrl);
return queryUrl
}

function mediaSearch(args, queryUrl){
queryUrl += ('/media/search?lat=' + args.lat + "&lng=" + args.lng + "&access_token=" + access_token);
console.log(queryUrl);
return queryUrl
}

function comments(args, queryUrl){
queryUrl += ('/media/' + args.media_id + "/comments?access_token=" + access_token);
console.log(queryUrl);
return queryUrl
}

function likes(args, queryUrl){
queryUrl += ('/media/' + args.media_id + "/likes?access_token=" + access_token);
console.log(queryUrl);
return queryUrl
}

function tagName(args, queryUrl){
queryUrl += ('/tags/' + args.tag_name + '?access_token=' + access_token);
console.log(queryUrl);
return queryUrl
}

function tagMediaRecent(args, queryUrl){
queryUrl += ('/tags/' + args.tag_name + '/media/recent?access_token=' + access_token);
console.log(queryUrl);
return queryUrl
}

function tagSearch(args, queryUrl){
queryUrl += ('/tags/search?q=' + args.q + '&access_token=' + access_token);
console.log(queryUrl);
return queryUrl
}

function locationID(args, queryUrl){
queryUrl += ('/locations/' + args.location_id + '?access_token=' + access_token);
console.log(queryUrl);
return queryUrl
}

function locationMediaRecent(args, queryUrl){
queryUrl += ('/locations/' + args.location_id + '/media/recent?access_token=' + access_token);
console.log(queryUrl);
return queryUrl
}

function locationSearch(args, queryUrl){
queryUrl += ('/locations/search?access_token=' + access_token);
for(var key in args){
queryUrl += '&' + key + '=' + encodeURIComponent(args[key]);
}
console.log(queryUrl);
return queryUrl
}

module.exports = {
instagram
}
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")
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
}
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
}

Loading

0 comments on commit e46e5be

Please sign in to comment.