#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; }