That's exactly where to submit features. Thanks. Traditional format
for a patch is to run "diff -u old_version new_version" and send the
output.
A similar method exists ("user_name") that returns the logged in
user's name, but this is a good idea. You also probably don't want
to set $self->{user_name} because that'd by convention be the logged
in user's name (i.e. the same as the method of the same name).
I've changed it to this - it'll be in version 0.20 right under
"user_name". (Patch from 0.19 to 0.20 below).
(btw, make sure you install version 0.19 - fixes a counting issue
with Comment.pm and Message.pm, and makes the tests work properly).
Oh, and I added you in the AUTHORS section - is the mention below
good? Would you like an email address included to help increase your
spam (or anything else)?
Index: Myspace.pm
===================================================================
RCS file: /export/home0/src/projects/WWW-Myspace/lib/WWW/Myspace.pm,v
retrieving revision 1.21
diff -u -r1.21 Myspace.pm
--- Myspace.pm 5 Feb 2006 03:01:59 -0000 1.21
+++ Myspace.pm 5 Feb 2006 06:24:25 -0000
@@ -38,11 +38,11 @@
=head1 VERSION
-Version 0.19
+Version 0.20
=cut
-our $VERSION = '0.19';
+our $VERSION = '0.20';
=head1 SYNOPSIS
@@ -299,6 +299,30 @@
}
+=head2 friend_user_name( friend_id )
+
+Returns the profile name of the friend specified by friend_id.
+This is the name that shows up at the top of their profile page
+above their picture. (Note, DON'T go using this to sign comments
+because most users use funky names and it'll just look cheesy.
+If you really want to personalize things, write a table mapping
+friend IDs to first names - you'll have to enter them yourself).
+
+=cut
+
+sub friend_user_name {
+
+ my $page = $self->get_profile( @_ );
+
+ # Pattern matching inside title tag. \s is needed because for
some
+ # reason myspace surrounds title text with whitespace:
+ if ( $page->content =~ /\<title\>[\s]*www.myspace\.com\/([\S]
*)[\s]*\<\/title\>/ ) {
+ return $1;
+ } else {
+ return "";
+ }
+}
+
=head2 friend_count
Returns the logged in user's friend count as displayed on the
@@ -1625,6 +1649,9 @@
Grant Grueninger, C<< <grantg at cpan.org> >>
+Thanks to:
+Tom Kerswill for the friend_user_name method.
+
=head1 KNOWN ISSUES
=over 4
On Feb 4, 2006, at 3:05 AM, Guest via RT wrote:
Show quoted text>
> Sat Feb 04 06:05:43 2006: Request 17476 was acted upon.
> Transaction: Ticket created by guest
> Queue: WWW-Myspace
> Subject: Patch submission for getting username
> Owner: Nobody
> Requestors: info@tomkerswill.co.uk
> Status: new
> Ticket <URL:
http://rt.cpan.org/Ticket/Display.html?id=17476 >
>
>
> Hi Grant...
>
> OK - I'm very new to Perl so I'm not sure whether this is the
> correct place to submit a patch.
> Sorry if it's something that is already in the script but I missed,
> but I thought it would be
> good to have a method to extract the person's username. Also
> apologies if it's rubbishly
> programmed ;-)
>
> WWW::Myspace is working great for me... really useful bit of kit.
> Cheers!
>
> Anyway, for what it's worth:
>
> #Begin added by Tom Kerswill
> =head2 get_user_name ($friend_id)
>
> Gives the user_name for a given friend_id. It looks inside the
> <title> tag of a myspace profile
> page.
>
> =cut
>
> sub get_user_name {
> my $page_source = $self->get_profile (@_);
> #Pattern matching inside title tag. \s is needed because for
> some reason myspace
> surrounds title text with whitespace:
> if ( $page_source->content =~ /\<title\>[\s]*www.myspace\.com\/
> ([\S]*)[\s]*\<\/title
> \>/ ) {
> $self->{user_name} = $1;
> }
> return $self->{user_name};
> }
>
> #End added by Tom Kerswill
>
>
>
>