diff options
Diffstat (limited to 'json-instagram/src')
| -rw-r--r-- | json-instagram/src/exampleApp.cpp | 55 | ||||
| -rw-r--r-- | json-instagram/src/exampleApp.h | 15 | ||||
| -rw-r--r-- | json-instagram/src/main.cpp | 6 |
3 files changed, 76 insertions, 0 deletions
diff --git a/json-instagram/src/exampleApp.cpp b/json-instagram/src/exampleApp.cpp new file mode 100644 index 0000000..0559dce --- /dev/null +++ b/json-instagram/src/exampleApp.cpp @@ -0,0 +1,55 @@ +#include "exampleApp.h" + +/* +so far so good, NOW + +threading + +parse response and identify new pictures +save pictures & metadata - rather than reloading each time? +local images format +do we need any metadata? I guess not other than to know the tag id +could save with the tag id as the name of file, simpler + +how exactly do we parse or mipmap the images +do we worry about memory - I guess not + +*/ + +//------------------------------------------------------------------------------ +void exampleApp::setup() +{ + ofSetFrameRate(24); + + std::string url = "https://api.instagram.com/v1/tags/tycleeson/media/recent?client_id=c1d74d701fdf4ddd9f8d30ee9e8f944b"; + + if (!response.open(url)) { + cout << "Failed to parse JSON\n" << endl; + } + //else cout<<response.getRawString()<<endl; + + + int numImages = MIN(5,response["data"].size()); + for(int i=0; i< numImages; i++) { + std::string url = response["data"][i]["images"]["standard_resolution"]["url"].asString(); + std::string id = response["data"][i]["caption"]["id"].asString(); + cout<<"fetching "<<id<<":"<<url<<endl; + + + ofImage img; + img.loadImage(url); + images.push_back( img ); + } + + +} + +//------------------------------------------------------------------------------ +void exampleApp::draw() +{ + ofBackground(0); + + for(int i=0; i<images.size(); i++) { + images[i].draw(i*30, i*30); + } +} diff --git a/json-instagram/src/exampleApp.h b/json-instagram/src/exampleApp.h new file mode 100644 index 0000000..1dcb032 --- /dev/null +++ b/json-instagram/src/exampleApp.h @@ -0,0 +1,15 @@ +#pragma once + + +#include "ofMain.h" +#include "ofxJSONElement.h" + + +class exampleApp : public ofBaseApp { +public: + void setup(); + void draw(); + + ofxJSONElement response; + std::vector<ofImage> images; +}; diff --git a/json-instagram/src/main.cpp b/json-instagram/src/main.cpp new file mode 100644 index 0000000..1c07795 --- /dev/null +++ b/json-instagram/src/main.cpp @@ -0,0 +1,6 @@ +#include "exampleApp.h" + +int main() { + ofSetupOpenGL(800,700,OF_WINDOW); + ofRunApp(new exampleApp()); +} |
