i needed a way to get the http link to the users main image and i saw nothing like it, so i decided to write my own.
It would be cool if this could be put into something like
CPAN::Forum
WWW-Myspace - code for getting user's main image
| Posted on Wed Jun 7 00:10:07 2006 by plasma2002 |
| code for getting user's main image |
|
i needed a way to get the http link to the users main image and i saw nothing like it, so i decided to write my own. It would be cool if this could be put into something like $myspace->get_image($id) but yeah, heres a snippet from one of my scripts:
my $page_source = $myspace->current_page->content;
if ( $page_source =~ /imgDefaultImage" src="([^\&]+)\_m.jpg/ ) {
$image_link = $1."_s.jpg";
}else{
$image_link = "0";
}
basically it grabs the image link from the current page.... MY script only calls it right after it logs in with the account, so its on the users homepage, so make sure its on the right page first before you try to get the image link. also, the REGEX only gets JPG's and not GIF's like some people have..... i know its simple enough to make it search for either, but it took me long enough to figure out that regex as it is, haha.... regex's are my kryptonite for sure. :) ALSO... (heh), on the users homepage, theres a medium sized picture... i grab the url for it (which ends in _m.jpg, and i replace that with _s.jpg. That makes your link the small thumbnail sized one. The three suffixes are _s.jpg, _m.jpg, and _l.jpg. _l gives you the original size the photo was uploaded in. :) So yeah.... i just thought it would be kinda cool if this was worked into a function in a future version somehow :P -Plasma2002, aka Brian, aka Schwippy |
| Write a response |
(2)
]