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.
IndexProgramming Questions & HelpOther Libraries › using proxml with flickr
Page Index Toggle Pages: 1
using proxml with flickr (Read 1643 times)
using proxml with flickr
Dec 7th, 2006, 4:04am
 
I am trying to use proxml library and here is my current code, the processing launches the applet then gives me the error:
proXML was not able to load the given xml-file: love.xml. Please check if you have entered the correct url..

am I missing something?


here is my code:

import proxml.*;

PImage loveImages[];
PImage oldImages[];
String proxyurl = "http://myURLhere/proxy.php?url=";


int rating = 0;

void setup() {
 size(750,750);
 loveImages = getImages("love", 100);
 oldImages = getImages("old", 100);
}

void draw() {

 for (int i = 0; i < loveImages.length; i++) {
   if (i >= rating) {
     image(loveImages[i], (i % 10) * 75, (i/10) * 75);
   }
   else {
     image(oldImages[i], (i % 10) * 75, (i/10) * 75);
   }
 }

/*  for (int i = 0; i < oldImages.length; i++) {
   if (i > rating) {
     image(oldImages[i], (i % 10) * 75, (i/10) * 75);
   }
 } */

}

PImage[] getImages(String tags, int imageCount) {

 XMLInOut xml;
 XMLElement rsp;
 XMLElement photos;

 xml = new XMLInOut(this);
 String request = tags + ".xml";
 println(request);
 rsp = xml.loadElementFrom(request);
 photos = rsp.getChild(0);
 rsp.printElementTree(" ");

 PImage images[] = new PImage[photos.countChildren()];

 XMLElement photo;
 for (int i = 0; i < photos.countChildren(); i++) {
   photo = photos.getChild(i);
   String url = "http://static.flickr.com/" +
     photo.getAttribute("server") + "/" +
     photo.getAttribute("id") + "_" +
     photo.getAttribute("secret") + "_s.jpg";
   println(url);
   images[i] = loadImage(proxyurl + url);
 }

 return images;

}

void keyPressed() {
 if (keyCode == RIGHT) {
 rating = rating +1;
} else if (keyCode == LEFT) {
   rating = rating -1;
 }
 rating = constrain(rating,0,100);
 println(rating);
}
Re: using proxml with flickr
Reply #1 - Dec 8th, 2006, 8:47pm
 
Have you tried to get the flickr response directly without the proxy locally? I have tried this:

Code:

package proxml.test;

import processing.core.PApplet;
import processing.core.PImage;
import proxml.XMLElement;
import proxml.XMLInOut;

public class Flickr2 extends PApplet{

PImage loveImages[];
PImage oldImages[];

String proxyurl = "http://myURLhere/proxy.php?url=";

int rating = 0;

String url = "http://www.flickr.com/services/rest/?api_key=yourkey&method=flickr.photos.search&per_page=5&page=2&tags=";

public void setup(){
size(750, 750);
if(online)url = proxyurl +url;
loveImages = getImages("love", 100);
oldImages = getImages("old", 100);
}

public void draw(){
for (int i = 0; i < loveImages.length; i++){
if (i >= rating){
image(loveImages[i], (i % 10) * 75, (i / 10) * 75);
}else{
image(oldImages[i], (i % 10) * 75, (i / 10) * 75);
}
}
}

PImage[] getImages(String tags, int imageCount){
XMLInOut xml;
XMLElement rsp;
XMLElement photos;

xml = new XMLInOut(this);
rsp = xml.loadElementFrom(url+tags);
photos = rsp.getChild(0);

rsp.printElementTree(" ");

PImage images[] = new PImage[photos.countChildren()];

XMLElement photo;

for (int i = 0; i < photos.countChildren(); i++){
photo = photos.getChild(i);
String url = "http://static.flickr.com/" +
photo.getAttribute("server") + "/" +
photo.getAttribute("id") + "_" +
photo.getAttribute("secret") + "_s.jpg";

println(url);
images[i] = loadImage(url);
}
return images;
}

public void keyPressed(){
if (keyCode == RIGHT){
rating = rating + 1;
}else if (keyCode == LEFT){
rating = rating - 1;
}
rating = constrain(rating, 0, 100);
println(rating);
}

public static void main(String[] args){
PApplet.main(new String[] {Flickr2.class.getName()});
}
}



And it worked fine.
Page Index Toggle Pages: 1