flickrSig
flickrSig
I'm writing up a little doo-dad that will let you put thumbnails of images stored in flickr in you sig here on NAM.
First off, if all you want to do is put a specific picture's thumbnail in your sig, that's easy... find the image in flickr, click on the "All Sizes" button on the images page, click on the "thumbnail" link, grab the URL from where it says "1. Grab the photo's URL:", and put it inside an [img] tag, so it looks like this:
[img]https://static.flickr.com/5/9845471_703350e9e7_t.jpg[/img]
That will put a specific image's thumbnail in your signature (or in a post, for that matter). Great.
But, what if you want your signature to always contain your most recent upload to flickr? Here's what you can do:
[img]http://joshwardell.com/snid/flickrSig.php5?u=username&n=number[/img]
where username is you flickr username, and number is how far back in your photostream to go - 0 is the most recent photo, 1 is the photo before that, etc - I think you can only go back to photo 9... trying 10 breaks things.
So, as an example, [img]http://joshwardell.com/snid/flickrSig.php5?u=snid&n=0[/img] would load my most recent flickr upload's thumbnail. Like this:
Doing a sig like this:
[img]http://joshwardell.com/snid/flickrSig.php5?u=snid&n=0[/img] [img]http://joshwardell.com/snid/flickrSig.php5?u=snid&n=1[/img] [img]http://joshwardell.com/snid/flickrSig.php5?u=snid&n=2[/img] [img]http://joshwardell.com/snid/flickrSig.php5?u=snid&n=3[/img] [img]http://joshwardell.com/snid/flickrSig.php5?u=snid&n=4[/img]
will display my five most recent uploads:

No we're getting somewhere... Josh said "how about a random photo?" Alright, use "r" for the number, and you'll get a random photo. Like this: [img]http://joshwardell.com/snid/flickrSig.php5?u=snid&n=r[/img]
Like this:

Unfortunately, if you try to put a bunch of random photos together, they all wind up being the same. Like this:

There might be a way to fix that, but it doesn't work right now.
Since Juan created the northamericanminiacs group in flickr, I decided it would only make sense to work with groups instead of users if you wanted to. So, you can make URLs like this:
[img]http://joshwardell.com/snid/flickrSig.php5?g=groupname&n=number[/img]
Notice the use of g instead pf u. For example, this will grab the most recent upload to the "northamericanminiacs" group:
[img]http://joshwardell.com/snid/flickrSig.php5?g=northamericanminiacs&n=0[/img]
Like this:

Or, a random picture from the group:
[img]http://joshwardell.com/snid/flickrSig.php5?g=northamericanminiacs&n=r[/img]
Like this:

but there's still the same problem with trying to get more than one different random picture at a time.
I'll probably add some more goodies in the future, like stuff to let you make the pictures be links to the picture in flickr.
The biggest problem with using this stuff as a signature here on NAM is that signatures are capped at 300 characters, and URLs are kinda long.
First off, if all you want to do is put a specific picture's thumbnail in your sig, that's easy... find the image in flickr, click on the "All Sizes" button on the images page, click on the "thumbnail" link, grab the URL from where it says "1. Grab the photo's URL:", and put it inside an [img] tag, so it looks like this:
[img]https://static.flickr.com/5/9845471_703350e9e7_t.jpg[/img]
That will put a specific image's thumbnail in your signature (or in a post, for that matter). Great.
But, what if you want your signature to always contain your most recent upload to flickr? Here's what you can do:
[img]http://joshwardell.com/snid/flickrSig.php5?u=username&n=number[/img]
where username is you flickr username, and number is how far back in your photostream to go - 0 is the most recent photo, 1 is the photo before that, etc - I think you can only go back to photo 9... trying 10 breaks things.
So, as an example, [img]http://joshwardell.com/snid/flickrSig.php5?u=snid&n=0[/img] would load my most recent flickr upload's thumbnail. Like this:
Doing a sig like this:
[img]http://joshwardell.com/snid/flickrSig.php5?u=snid&n=0[/img] [img]http://joshwardell.com/snid/flickrSig.php5?u=snid&n=1[/img] [img]http://joshwardell.com/snid/flickrSig.php5?u=snid&n=2[/img] [img]http://joshwardell.com/snid/flickrSig.php5?u=snid&n=3[/img] [img]http://joshwardell.com/snid/flickrSig.php5?u=snid&n=4[/img]
will display my five most recent uploads:
No we're getting somewhere... Josh said "how about a random photo?" Alright, use "r" for the number, and you'll get a random photo. Like this: [img]http://joshwardell.com/snid/flickrSig.php5?u=snid&n=r[/img]
Like this:
Unfortunately, if you try to put a bunch of random photos together, they all wind up being the same. Like this:
There might be a way to fix that, but it doesn't work right now.
Since Juan created the northamericanminiacs group in flickr, I decided it would only make sense to work with groups instead of users if you wanted to. So, you can make URLs like this:
[img]http://joshwardell.com/snid/flickrSig.php5?g=groupname&n=number[/img]
Notice the use of g instead pf u. For example, this will grab the most recent upload to the "northamericanminiacs" group:
[img]http://joshwardell.com/snid/flickrSig.php5?g=northamericanminiacs&n=0[/img]
Like this:
Or, a random picture from the group:
[img]http://joshwardell.com/snid/flickrSig.php5?g=northamericanminiacs&n=r[/img]
Like this:
but there's still the same problem with trying to get more than one different random picture at a time.
I'll probably add some more goodies in the future, like stuff to let you make the pictures be links to the picture in flickr.
The biggest problem with using this stuff as a signature here on NAM is that signatures are capped at 300 characters, and URLs are kinda long.
Nice work, guys! Couple of comments. Trying to retrieve multiple random images probably won't work until you add a parameter to the URL. I'm thinking that the browser just uses the first image returned every time it sees that URL. The browser (or at least smart ones) doesn't make 1,000 requests to nam.com every time MINIClo posts with 1,000 smilies, right? ;-)
2nd, you *could* use something like tinyurl.com to "compress" the URLs, thus getting around the 300 character space cap.
It's a shame I won't be able to see the fruits of your labors; I've got signatures turned off. :-)
2nd, you *could* use something like tinyurl.com to "compress" the URLs, thus getting around the 300 character space cap.
It's a shame I won't be able to see the fruits of your labors; I've got signatures turned off. :-)
Yup, that's the trick to different random photos - the URLs have to be different. Stick something like &1 on the end of the URL, but with a different number to make the URLs different, and you get different images. Like so:
[img]http://joshwardell.com/snid/flickrSig.php5?u=snid&n=r&1[/img]
[img]http://joshwardell.com/snid/flickrSig.php5?u=snid&n=r&2[/img]
[img]http://joshwardell.com/snid/flickrSig.php5?u=snid&n=r&3[/img]



I think I'll make it a little easier to understand, though, and do something like n=r1, n=r2,etc... but not tonight.
[img]http://joshwardell.com/snid/flickrSig.php5?u=snid&n=r&1[/img]
[img]http://joshwardell.com/snid/flickrSig.php5?u=snid&n=r&2[/img]
[img]http://joshwardell.com/snid/flickrSig.php5?u=snid&n=r&3[/img]
I think I'll make it a little easier to understand, though, and do something like n=r1, n=r2,etc... but not tonight.
Originally Posted by blalor
Would you mind making your source available? I've got a couple of things I wouldn't mind trying, just for the heck of it....
No problem. All the hard work was done by someone else, anyway.
The flickr specific stuff is from this php library: http://www.drewish.com/projects/phlickr/
Here's the code I wrote (as it stands right now). My flickr API key and secret number have been removed from the code, just becuase:
#!/usr/local/php5/bin/php -q
<?php
require_once 'Phlickr/Api.php';
require_once 'Phlickr/User.php';
define('FLICKR_API_KEY', 'my key - get your own');
define('FLICKR_API_SECRET', 'my secret');
$api = new Phlickr_Api(FLICKR_API_KEY, FLICKR_API_SECRET);
$username=$_GET["u"];
$groupname=$_GET["g"];
$photoNum=$_GET["n"];
if(!empty($groupname)){
$group = Phlickr_Group::findByUrl($api, "http://flickr.com/groups/".$groupname."/");
$photolist = $group->getPhotoList();
}
if(!empty($username)){
$user = Phlickr_User::findByUsername($api, $username);
$photolist = $user->getPhotoList();
}
if($photoNum=="r"){
$url=$photolist->getRandomPhoto()->buildImgUrl(Phlickr_Photo::SIZE_100PX);
}
else{
$photos = $photolist->getPhotos();
$url=$photos[$photoNum]->buildImgUrl(Phlickr_Photo::SIZE_100PX);
}
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header('location:'.$url);
?>
This is my first ever php script, and I would still say that I know nothing about PHP.
What I was thinking is that, although it's cool to have the pictures there, they're awful small, and you've got no way to get to the image's page on Flickr. Wrapping them in a \[url\] block would be the way to go, in my opinion. It'd be tricky to do that, however, given the limitations of this (stupid) bulletin board software. Yes, I really do loathe vBulletin... :-)
One idea (persistence mechanism warning!) might be to keep track of the referrer (and possibly also use a cookie) so that you could do something like this:
[url=http://example.com/flickrSigLink?n=r&u=blalor&ind=0][img]http://example.com/flickrSigImg?n=r&u=blalor&ind=0[/img][/url]
[url=http://example.com/flickrSigLink?n=r&u=blalor&ind=1][img]http://example.com/flickrSigImg?n=r&u=blalor&ind=1[/img][/url]
...
ad infinitum
Er, or something like that. Bedtime, now.
One idea (persistence mechanism warning!) might be to keep track of the referrer (and possibly also use a cookie) so that you could do something like this:
[url=http://example.com/flickrSigLink?n=r&u=blalor&ind=0][img]http://example.com/flickrSigImg?n=r&u=blalor&ind=0[/img][/url]
[url=http://example.com/flickrSigLink?n=r&u=blalor&ind=1][img]http://example.com/flickrSigImg?n=r&u=blalor&ind=1[/img][/url]
...
ad infinitum
I don't know a thing about what you guys are discussing here but I can see the passion, and that's good. 
As for me, I'm happy to have helped generate at least some interest in all this.
As for me, I'm happy to have helped generate at least some interest in all this.
Trending Topics
Awesome job jason--I didn't realize you kept on working on it after you got it working.
Now for a request
Add Set capability. So you can make a specific set of photos that you want to display in your signature. That's exactly what I do for the top of my MINI page.
Now for a request
Add Set capability. So you can make a specific set of photos that you want to display in your signature. That's exactly what I do for the top of my MINI page.
I just checked bandwidth. No major change. There is a detectable jump in requests. Nothing major.
edit: hmm. nam must ignore the code tag. Pretend those columns line up.
Code:
Total HTTP FTP/SFTP Mail Date Megabytes Requests Megabytes Requests Megabytes Requests Megabytes Quantity 2006-01-12 18.93 1,897 18.925 1,897 0.000 0 0.000 0 2006-01-11 85.78 2,269 85.782 2,269 0.000 0 0.000 0 2006-01-10 209.15 2,477 163.980 2,475 45.166 2 0.000 0 2006-01-09 215.02 1,547 214.874 1,520 0.144 27 0.000 0 2006-01-08 46.31 823 46.306 823 0.000 0 0.000 0 2006-01-07 109.64 790 109.639 790 0.000 0 0.000 0 2006-01-06 111.75 1,323 111.747 1,323 0.000 0 0.000 0 2006-01-05 106.93 1,637 106.930 1,637 0.000 0 0.000 0 2006-01-04 10.07 1,516 10.075 1,516 0.000 0 0.000 0 2006-01-03 17.44 1,302 17.443 1,302 0.000 0 0.000 0 2006-01-02 40.40 1,540 40.402 1,540 0.000 0 0.000 0 2006-01-01 62.07 717 62.067 717 0.000 0 0.000 0


