We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProcessing DevelopmentLibraries,  Tool Development › Flickr Authentication with Flickrj
Page Index Toggle Pages: 1
Flickr Authentication with Flickrj (Read 1228 times)
Flickr Authentication with Flickrj
Aug 27th, 2009, 2:53pm
 
Can someone who understands Flickrj help me with authentication? I'm trying to find photos of seattle with a geo script I've loosely compiled from:

http://www.bryanchung.net/?p=189


This is what I have so far. I don't understand how to authenticate with 'read permission' either with or without Flickrj


import com.aetrion.flickr.auth.*;
import proxml.*;

String userName = "YOUR_USER_NAME";
String apiKey = "YOUR_API_KEY";
String nsid = "";
String url = "http://api.flickr.com/services/rest/";
XMLInOut xml = null;

Flickr f;
AuthInterface a;

void setup() {
 size(600,600);
 background(0);
 frameRate(15);
 xml = new XMLInOut(this);
 f= new Flickr(apiKey);
 a = f.getAuthInterface();
}

void draw() {
}

void mousePressed() {
 nsid = "";
 findByUsername(userName);
}

void findByUsername(String _n) {
 String rest = url+"?method=flickr.people.findByUsername";
 rest += "&api_key=" + apiKey;
 rest += "&username=" + _n;
 xml.loadElement(rest);
}

void getFrob(String _n) {
 String rest = url+"?method=flickr.auth.getFrob"


void getPublicPhotos(String _n) {
 String rest = url+"?method=flickr.photos.geo.photosForLocation";
 rest += "&api_key=" + apiKey;
 rest += "&user_id=" + nsid;
 rest += "&lat=47";
 rest += "&lon=122";
 xml.loadElement(rest);
}

void xmlEvent(proxml.XMLElement _x) {
 parseXML(_x);
}

void parseXML(proxml.XMLElement _x) {
 String stat = _x.getAttribute("stat");
 if (!stat.equals("ok")) {
   println("Error from Flickr");
   return;
 }
 proxml.XMLElement node = _x.getChild(0);
 String type = node.getName();
 if (type.equals("user")) {
   nsid = node.getAttribute("nsid");
   println(nsid);
   getPublicPhotos(nsid);
 }
 else if (type.equals("photos")) {
   int num = node.countChildren();
   println(num);
   getPhotos(node);
 }
}

void getPhotos(proxml.XMLElement _n) {
 int cnt = _n.countChildren();
 cnt = min(cnt,64);
 for (int i=0;i<cnt;i++) {
   proxml.XMLElement ph = _n.getChild(i);
   String fm = ph.getAttribute("farm");
   String sv = ph.getAttribute("server");
   String id  = ph.getAttribute("id");
   String sc = ph.getAttribute("secret");
   String imgURL = "http://farm"+fm+".static.flickr.com/"+
     sv + "/" + id + "_" + sc + "_s.jpg";
   PImage img = loadImage(imgURL);
   int x = (i%8) * img.width;
   int y = (i/8) * img.height;
   image(img,x,y);
 }
}
Page Index Toggle Pages: 1