summaryrefslogtreecommitdiff
path: root/json-instagram/src
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2014-03-10 12:40:45 +0000
committerTim Redfern <tim@eclectronics.org>2014-03-10 12:40:45 +0000
commit2a6b5328dec0ef2200bdbb94b16e8531c7c071b2 (patch)
treec77bf8ceb17748ad2fd89f5274b73f42c54329f9 /json-instagram/src
parent9301d02887e2d75457c3ee885418f44846ca3143 (diff)
getting images from instagram
Diffstat (limited to 'json-instagram/src')
-rw-r--r--json-instagram/src/exampleApp.cpp55
-rw-r--r--json-instagram/src/exampleApp.h15
-rw-r--r--json-instagram/src/main.cpp6
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());
+}