Subject: | Added sendername, fixed documentation |
Date: | Thu, 17 Jan 2008 17:55:01 -0800 |
To: | bug-www-myspace [...] rt.cpan.org |
From: | "Rob Perelman" <rob [...] veerob.com> |
===================================================================
--- trunk/WWW-Myspace/lib/WWW/Myspace.pm (revision 549)
+++ trunk/WWW-Myspace/lib/WWW/Myspace.pm (working copy)
@@ -3586,12 +3586,15 @@
}
+# Updated by veeRob on 1/16/08 to document sendername
+# Updated by veeRob on 1/17/08 to change example from inbox() to
get_inbox()
=head2 get_inbox ( %options )
Returns a reference to an array of hash references that contain data
about the messages in your Myspace message inbox. The hashes contain:
sender (friendID)
+ sendername (friend's display name)
status (Read, Unread, Sent, Replied)
message_id (The unique ID of the message)
subject (The subject of the message)
@@ -3627,11 +3630,12 @@
$myspace = new WWW::Myspace;
print "Getting inbox...\n";
- my $messages = $myspace->inbox;
+ my $messages = $myspace->get_inbox;
# Display data for each message
foreach $message ( @{$messages} ) {
print "Sender: " . $message->{sender} . "\n";
+ print "Sendername: " . $message->{sendername} . "\n";
print "Status: " . $message->{status} . "\n";
print "messageID: " . $message->{message_id} . "\n";
print "Subject: " . $message->{subject} . "\n\n";
@@ -3708,6 +3712,7 @@
# Return a list of message data from the current page
# Updated by WZorn to fix hanging problem on Mandriva and RetHat linux.
+# Updated by veeRob on 1/16/08 to save the sender's name
sub _get_messages_from_page {
my ( %options ) = @_;
@@ -3718,6 +3723,7 @@
# 1 - In message block, looking for
data
# Will return to state=0 when we
get the last data (messageID and subject)
my $sender;
+ my $sendername;
my $status;
my $msg_id;
my $subject;
@@ -3729,8 +3735,9 @@
if(/<td class="messageListCell" align="center">/){
# Found beginning of Message block
$state = 1;
- } elsif (/viewprofile&friendid=([0-9]+)/ && $state == 1){
+ } elsif (/viewprofile&friendid=([0-9]+)"?>([^<>]+)</ && $state ==
1){
$sender = $1;
+ $sendername = $2;
} elsif (/(Unread|Read|Sent|Replied)/ && $state == 1){
$status = $1;
} elsif (/messageID=([^&]+)&.*?>(.+?)<\/a>/ && $state == 1){
@@ -3738,8 +3745,8 @@
$subject = $2;
$state = 0; #return to state=0 because we need to start
looking for the beginning of the next message block
- push @messages, { sender => $sender, status => $status,
message_id=> $msg_id, subject => $subject };
- if ($DEBUG) { print
$sender,"|",$status,"|",$msg_id,"|",$subject,"\n"; }
+ push @messages, { sender => $sender, sendername =>
$sendername, status => $status, message_id=> $msg_id, subject => $subject };
+ if ($DEBUG) { print
$sender,"|",$sendername,"|",$status,"|",$msg_id,"|",$subject,"\n"; }
}
}
return @messages;