JS mode problems: Instagram JSON to load images

edited March 2014 in JavaScript Mode

I'm having problems with using JSON to grab images from instagram in Javascript mode.

JSONObject jsonAgram;
PImage displayInstaImage1;

String apiKey = "xxxxxxxxxxxxx";  //needs valid Instagram API key 
String tagSearch;

void setup() {
  println("setup");

  size(320,320);
  tagSearch = "pizza";
  loadData();  
}

void draw() {
  println("draw"); 

  image(displayInstaImage1,0,0);
}



void loadData() {
  println("loadData1"); 

  //doesn't seem to make it past the this point
  jsonAgram = loadJSONObject("https://api.instagram.com/v1/tags/"+tagSearch+"/media/recent?client_id="+ apiKey);
  println("loadData2");

  JSONArray instagramData = jsonAgram.getJSONArray("data");
  JSONObject entry1 = instagramData.getJSONObject(0);
  JSONObject image1Data = entry1.getJSONObject("images").getJSONObject("low_resolution"); 

  String image1URL = image1Data.getString("url");

  displayInstaImage1 = loadImage(image1URL);      
}

Same old song and dance: works fine in Java mode, but not Javascript. When I run it in JS, it shows up as a gray screen. Using println commands to debug, it looks like things move along until I use "loadJSONObject".

Does the JSON functionality work with JS mode? I know certain libraries won't, but since JSON was integrated into Processing native libraries I thought it should work.

Or could it be something else I'm missing? It would be nice to have a clearer understanding of what will and won't work in Javascript mode.

Answers

Sign In or Register to comment.