api - Instagram & Processing - Real time view -


i'm working on small app similar instaprint , need help. i'm using source code globalgram andrew haskin, searches instagram particular hashtag , displays recent image posted hashtag. problem once, need continuously search hashtag , display image when new 1 added, refresh, i've been tinkering no avail. appreciated

code below :

import com.francisli.processing.http.*;  pfont instagramfont; pimage backgroundimg; pimage brand; pimage userphoto; pimage profilepicture;  string username; string tag; string[] tagstrings;   com.francisli.processing.http.httpclient client;  void setup() {   size(580, 900);   smooth();   backgroundimg = loadimage("iso_background.jpg");   brand = loadimage("iso.jpg");    instagramfont = loadfont("helvetica-bold-36.vlw");    client = new com.francisli.processing.http.httpclient(this, "api.instagram.com");   client.usessl = true;    //// instantiate new hashmap   hashmap params = new hashmap();   //// put key/value pairs want send in request   params.put("access_token", "------access token here------");   params.put("count", "1");   client.get("/v1/tags/coffee/media/recent.json", params); }  void responsereceived(com.francisli.processing.http.httprequest request, com.francisli.processing.http.httpresponse response) {   println(response.getcontentasstring());    //// server response json object   com.francisli.processing.http.jsonobject content = response.getcontentasjsonobject();    //// "data" value, array   com.francisli.processing.http.jsonobject data = content.get("data");    //// first element in array   com.francisli.processing.http.jsonobject first = data.get(0);    //// "user" value dictionary, can "full_name" string value   println(first.get("user").get("full_name").stringvalue());   //// "caption" value dictionary, can "text" string value   //println(first.get("caption").get("text").stringvalue());   //// profile picture   println(first.get("user").get("profile_picture").stringvalue());   //// "images" value dictionary, can different image url data   println(first.get("images").get("standard_resolution").get("url").stringvalue());    com.francisli.processing.http.jsonobject tags = first.get("tags");   tagstrings = new string[tags.size()];   (int = 0; < tags.size(); i++) {     tagstrings[i] = tags.get(i).stringvalue();   }     username = first.get("user").get("full_name").stringvalue();     string profilepicture_url = first.get("user").get("profile_picture").stringvalue();   profilepicture = loadimage(profilepicture_url, "png");    string userphoto_url = first.get("images").get("standard_resolution").get("url").stringvalue();   userphoto = loadimage(userphoto_url, "png");   //noloop(); }   void draw() {   background(255);   imagemode(center);   image(brand, 100, height/1.05);     if (profilepicture != null) {     image(profilepicture, 60, 70, 90, 90);   }   imagemode(center);   if (userphoto != null) {     image(userphoto, width/2, height/2.25, 550, 550);   }    textfont(instagramfont, 20);   if (username != null) {     text(username, 110, 115);     fill(0);   }     textfont(instagramfont, 15);   if ((tagstrings != null) && (tagstrings.length > 0)) {     string line = tagstrings[0];     (int = 1; < tagstrings.length; i++) {       line += ", " + tagstrings[i];     }     text(line, 25, 720, 550, 50);     fill(0);   }  } 

afaik should

client.get("/v1/tags/coffee/media/recent.json", params); 

line polls instagram. try wrapping in function this:

void getgrams() {   client.get("/v1/tags/coffee/media/recent.json", params); } 

then call once in setup() , again when want ...

i'd start trying on mousepressed() or keypressed(), fires once when want to

don't try in draw() without timer (something if(framecount % 5000 == 0) fire every 5 seconds ((which may fast still idea))


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -