 |
Author |
Topic: More on Processing, XML, PHP and new JRE problems? (Read 2670 times) |
|
TomC
|
More on Processing, XML, PHP and new JRE problems?
« on: Aug 25th, 2004, 5:01pm » |
|
I made a couple of PHP scripts to redirect images and XML from Flickr. This is the first time I've written more than 2 lines of PHP - any PHP-heads want to comment on these? This one redirects images: Code: <?php $PHOTO_URL = "http://www.flickr.com/photos/"; $USER = $_GET['owner']; $PHOTO = $_GET['id']; if ($USER && $PHOTO) { $PHOTO_URL .= $PHOTO."_".$USER."_s.jpg"; $fp = fopen($PHOTO_URL, "rb"); fpassthru($fp); } ?> |
| This one redirects API calls (XML): Code: // NB: your api key needs inserting in this file <?php $API_KEY = "INSERT YOUR API KEY HERE"; $REST_URL = "http://www.flickr.com/services/rest/?api_key=".$API_KEY; $METHOD = $_GET['method']; $TAGS = $_GET['tags']; $PER_PAGE = $_GET['per_page']; if ($METHOD && $TAGS && $PER_PAGE) { $REST_URL.="&method=".$METHOD."&tags=".$TAGS."&per_page=".$PER_PAGE; readfile($REST_URL); } ?> |
| The applet I'm using this for (Flickr Rainbow) is here: http://www.tom-carden.co.uk/p5/flickr_rainbow2/applet/index.html and it also uses nanoxml to get the data. Unfortunately, it seems to break in the new Sun JRE 1.5. Any ideas?
|
« Last Edit: Aug 25th, 2004, 5:02pm by TomC » |
|
|
|
|
Euskadi
|
Re: More on Processing, XML, PHP and new JRE probl
« Reply #1 on: Aug 27th, 2004, 2:19am » |
|
I hesitate to call myself a PHP-head, but in case you don't get any other responses, I'll jump in.... on Aug 25th, 2004, 5:01pm, TomC wrote: On this line, it looks like you are trying to test to see if $USER and $PHOTO have values If that's the case use this to see if the variables have been set to something: Code: if(ISSET($USER) && ISSET($PHOTO)){ |
| The way the line reads now, it looks like $USER and $PHOTO are supposed to contain "TRUE" or "FALSE" which I kinda doubt. Oh, and ditto for your second code snippet. Not sure about readfile() and fpassthrough(), they are new to me... And, guessing you know this already, you need to enter a real api key in the $API_KEY variable. on Aug 25th, 2004, 5:01pm, TomC wrote: Code: $API_KEY = "INSERT YOUR API KEY HERE"; |
| |
|
|
|
|
|
fjen
|
Re: More on Processing, XML, PHP and new JRE probl
« Reply #2 on: Aug 27th, 2004, 9:20am » |
|
i suggest you rather use empty() here, cause they are set in any way ("" is not null) by: $USER = $_GET['user']; test like this: if ( !empty($USER) && !empty($PHOTO) ) { ... no idea about the new Sun JRE 1.5 ... sorry.
|
|
|
|
|