MINI Camera and Video Interested in capturing your motoring experience? Discuss here your favorite video and photography skills using your MINI.

flickrSig

Thread Tools
 
Search this Thread
 
Old Jan 10, 2006 | 02:55 PM
  #1  
snid's Avatar
snid
Thread Starter
|
6th Gear
Joined: Jul 2002
Posts: 2,021
Likes: 4
From: Burlington, VT
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.
 
Reply
Old Jan 10, 2006 | 04:35 PM
  #2  
blalor's Avatar
blalor
6th Gear
Joined: Jan 2005
Posts: 1,231
Likes: 0
From: RVA
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. :-)
 
Reply
Old Jan 10, 2006 | 05:26 PM
  #3  
snid's Avatar
snid
Thread Starter
|
6th Gear
Joined: Jul 2002
Posts: 2,021
Likes: 4
From: Burlington, VT
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.
 
Reply
Old Jan 10, 2006 | 05:41 PM
  #4  
blalor's Avatar
blalor
6th Gear
Joined: Jan 2005
Posts: 1,231
Likes: 0
From: RVA
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....
 
Reply
Old Jan 10, 2006 | 05:51 PM
  #5  
snid's Avatar
snid
Thread Starter
|
6th Gear
Joined: Jul 2002
Posts: 2,021
Likes: 4
From: Burlington, VT
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....
There's no reason for the average Joe to read / understand this post.

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.
 
Reply
Old Jan 10, 2006 | 07:39 PM
  #6  
blalor's Avatar
blalor
6th Gear
Joined: Jan 2005
Posts: 1,231
Likes: 0
From: RVA
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.
 
Reply
Old Jan 10, 2006 | 09:11 PM
  #7  
blacknblue's Avatar
blacknblue
Photographer / Beer Dude
Joined: Jul 2003
Posts: 2,342
Likes: 0
From: SoCal (562)
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.
 
Reply
Old Jan 11, 2006 | 05:37 AM
  #8  
Minsian's Avatar
Minsian
2nd Gear
Joined: Dec 2005
Posts: 102
Likes: 0
From: Wilmington, DE
Awesome! I'm doing this right now! Thanks for putting work into this and thank you to jwardell for hosting the code...

man...ask and ye shall receive on NAM!
 
Reply
Old Jan 11, 2006 | 05:43 AM
  #9  
adame's Avatar
adame
Coordinator :: MINIsota Motoring Society (MMS)
Joined: Dec 2002
Posts: 874
Likes: 1
From: MPLS. MN
Wonderful job so far you guys! Thanks for the insight on this stuff.
 
Reply
Old Jan 11, 2006 | 06:40 AM
  #10  
AndyWSea's Avatar
AndyWSea
5th Gear
Joined: Nov 2005
Posts: 674
Likes: 0
From: Seattle, WA
This is awesome! Great job!
 
Reply
Old Jan 11, 2006 | 06:43 AM
  #11  
The Short Bus's Avatar
The Short Bus
6th Gear
Joined: May 2005
Posts: 4,061
Likes: 1
From: Richmond, VA
thanks for the help
 
Reply
Old Jan 13, 2006 | 09:54 AM
  #12  
jwardell's Avatar
jwardell
6th Gear
Joined: May 2004
Posts: 1,431
Likes: 0
From: Boston area
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.
 
Reply
Old Jan 13, 2006 | 09:57 AM
  #13  
jwardell's Avatar
jwardell
6th Gear
Joined: May 2004
Posts: 1,431
Likes: 0
From: Boston area
I just checked bandwidth. No major change. There is a detectable jump in requests. Nothing major.
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
edit: hmm. nam must ignore the code tag. Pretend those columns line up.
 
Reply
Old Jan 13, 2006 | 10:24 AM
  #14  
blacknblue's Avatar
blacknblue
Photographer / Beer Dude
Joined: Jul 2003
Posts: 2,342
Likes: 0
From: SoCal (562)
Originally Posted by jwardell
That's exactly what I do for the top of my MINI page.
Hey, that's cool Josh! And all this time I thought it was one of those Flickr Badges.
 
Reply
Old Jan 13, 2006 | 10:28 AM
  #15  
jwardell's Avatar
jwardell
6th Gear
Joined: May 2004
Posts: 1,431
Likes: 0
From: Boston area
It is a flickr badge. It gets the images out of a flickr set.
 
Reply




All times are GMT -7. The time now is 03:28 PM.