From d7eefb73403785845c3c6e9d77e09f2f9bdd4ff6 Mon Sep 17 00:00:00 2001 From: tim Date: Thu, 30 Mar 2017 00:15:52 +0100 Subject: ofxInstagram updates for addon lib --- ofxInstagram/ofxInstagram.cpp | 714 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 714 insertions(+) create mode 100644 ofxInstagram/ofxInstagram.cpp (limited to 'ofxInstagram/ofxInstagram.cpp') diff --git a/ofxInstagram/ofxInstagram.cpp b/ofxInstagram/ofxInstagram.cpp new file mode 100644 index 0000000..a264e8b --- /dev/null +++ b/ofxInstagram/ofxInstagram.cpp @@ -0,0 +1,714 @@ +#include "ofxInstagram.h" +#include +#pragma mark - Setup +//-------------------------------------------------------------- +void ofxInstagram::setup(string auth_token, string clientID) +{ + scrollValue = 0; + // Set the Tokens + _auth_token = auth_token; + _clientID = clientID; +} +//-------------------------------------------------------------- +void ofxInstagram::setCertFileLocation(std::string path) +{ + _certPath = path; + cout << _certPath << endl; +} +//-------------------------------------------------------------- +void ofxInstagram::drawJSON(int x) +{ + ofPushMatrix(); + ofTranslate(x, scrollValue); + ofDrawBitmapString(getParsedJSONString(), 0,0); + ofPopMatrix(); +} +#pragma mark - Scroll Stuff +//-------------------------------------------------------------- +void ofxInstagram::mouseScroll(int scrollY) +{ + scrollValue += scrollY; +} +//-------------------------------------------------------------- +void ofxInstagram::resetScroll() +{ + scrollValue = 0; +} +//-------------------------------------------------------------- +void ofxInstagram::saveJson(string filename) +{ + json.toStyledString(); + json.save(filename+".json"); +} +#pragma mark - User Endpoints +//-------------------------------------------------------------- +// * +// * USER ENDPOINTS +// * GET Info +// * GET User Feed +// * GET User Recent Media +// * GET User Like Media +// * GET User Search Users +// * +//-------------------------------------------------------------- +void ofxInstagram::getUserInformation(string who) +{ + stringstream url; + url << "https://api.instagram.com/v1/users/" << who << "/?access_token=" << _auth_token; + + cout << "Getting Info about User: This is your request: " << url.str() < ofxInstagram::getBasicData() +{ + deque data; + data.resize(json["data"].size()); + + for(unsigned int i = 0; i < json["data"].size(); ++i) + { + data[i].user = json["data"][i]["user"]["username"].asString(); + data[i].imageID = json["data"][i]["id"].asString(); + data[i].imageURL = json["data"][i]["images"]["low_resolution"]["url"].asString(); + data[i].created_at = json["data"][i]["created_time"].asString(); + data[i].caption = json["data"][i]["caption"]["text"].asString(); + } + return data; +} +//-------------------------------------------------------------- +deque ofxInstagram::getImageURL() +{ + dequeelements; + for(unsigned int i = 0; i < json["data"].size(); ++i){ + std::string title = json["data"][i]["images"]["standard_resolution"]["url"].asString(); + elements.push_back(title); + } + return elements; +} +//-------------------------------------------------------------- +deque ofxInstagram::getImageCaption() +{ + dequeelements; + for(unsigned int i = 0; i < json["data"].size(); ++i){ + std::string caption = json["data"][i]["caption"]["text"].asString(); + elements.push_back(caption); + } + return elements; +} +//-------------------------------------------------------------- +deque ofxInstagram::getVideoURL(){ + dequeelements; + for(unsigned int i = 0; i < json["data"].size(); ++i){ + std::string title = json["data"][i]["videos"]["standard_resolution"]["url"].asString(); + elements.push_back(title); + } + return elements; +} +//-------------------------------------------------------------- +deque ofxInstagram::getProfilePicture(){ + deque elements; + for(unsigned int i = 0; i < json["data"].size(); ++i){ + std::string profilePicture = json["data"][i]["user"]["profile_picture"].asString(); + elements.push_back(profilePicture); + } + return elements; +} +//-------------------------------------------------------------- +deque < deque > ofxInstagram::getTags(){ + deque < deque > elements; + for(unsigned int i = 0; i < json["data"].size(); ++i){ + deque subelements; + for(unsigned int j = 0; j < json["data"][i]["user"]["tags"].size(); ++j){ + std::string tag = json["data"][i]["user"]["tags"][j].asString(); + subelements.push_back(tag); + } + elements.push_back(subelements); + } + return elements; +} +//-------------------------------------------------------------- +deque ofxInstagram::getImageID() +{ + dequeelements; + for(unsigned int i = 0; i < json["data"].size(); ++i){ + std::string title = json["data"][i]["caption"]["id"].asString(); + elements.push_back(title); + } + return elements; +} -- cgit v1.2.3