Skip Menu |

This queue is for tickets about the WWW-Myspace CPAN distribution.

Report information
The Basics
Id: 17810
Status: resolved
Priority: 0/
Queue: WWW-Myspace

People
Owner: GRANTG [...] cpan.org
Requestors: Plasma2002 [...] sch.com
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: (no value)
Fixed in: (no value)



Subject: Function Ideas and samples
Per request, just some sample code i have for those functions i had described in the forum. You might want to download this page so the code will be more readable note that these were taken straight out of another script which handled an AIM bot, so each function handled multiple MySpace users and accounts. Be carefull if your copy and pasting. This is mainly just here for ideas. #------------------------------------------------------ #post_bulletin posts a bulletin on myspace for the account holder #------------------------------------------------------ sub post_bulletin{ $sender = shift; $subject = shift; $message = shift; $account = decode_base64($people_myspace_names{$sender}); $pass = decode_base64($people_myspace_passes{$sender}); my ( $submitted, $res, $page ); my $myspace = WWW::Myspace->new ($account, $pass); $my_id = $myspace->my_friend_id; print " Users friend id is: $my_id\n"; if(($my_id) > "1"){ #its good }else{ #bad username/pass load_arrays(); send_message($sender, "It looks like your MySpace username or password is incorrect. Please go to my page at $bot_page and update it"); return; } # Try to get the message form $res = $myspace->get_page( "${POST_BULLETIN_FORM}" ); # See if we can post or if there's an error. if ( $res->is_success ) { $page = $res->content; $page =~ s/[ \t\n\r]+/ /g; } else { print "there was an html error (1)\n"; send_message($sender, "There was a MySpace internal error. It was beyond my control. Sorry :("); return; } # Take care "\n"s $message =~ s/\\n/\n/gs; # Submit the message print " Submitting the first form... "; $submitted = $myspace->submit_form( $res, 1, "", { 'subject' => "$subject", 'body' => "$message" } ); $page = $myspace->{current_page}->content; $page =~ s/[ \t\n\r]+/ /g; print "success!\n"; if ( $res->is_success ) { $page = $res->content; $page =~ s/[ \t\n\r]+/ /g; }else{ print "there was an html error (2)\n"; send_message($sender, "There was a MySpace internal error. It was beyond my control. Sorry :("); return; } print " Submitting the confirmation form... "; $confirmed = $myspace->submit_form( $myspace->{current_page}, 1, "",{} ); print "success!\n"; $page = $myspace->{current_page}->content; $page =~ s/[ \t\n\r]+/ /g; # Return the result if (! $confirmed ) { print " there was an html error (3)\n"; send_message($sender, "There was a MySpace internal error. It was beyond my control. Sorry :("); return; } elsif ( $page =~ /$VERIFY_BULLETIN_SENT/ ) { print " SUCCESS ON BULLETIN!\n"; send_message($sender, "Your bulletin has successfully been posted :) Remember... you might have to give it up to 5 minutes before it shows up ;)"); return; } else { print " there was an html error (4)\n"; send_message($sender, "There was a MySpace internal error. It was beyond my control. Sorry :("); return; } print "Killing myspace\n\n"; #kill off the myspace class $myspace = '' } Heres a littl snippet i use in a function that grabs the friends on the top 8 list..... #lets get the top 8 friends $url = "http://home.myspace.com/index.cfm?fuseaction=user"; dbg (" Getting top 8 friends for $sender...\n"); $res=$myspace->get_page( $url ); $offset = index($res->content,"My Friend Space"); $content = substr($res->content,$offset) ; my @mylist = $myspace->get_friends_on_page( $content ); dbg (" Got top 8 friends\n"); #got top 8 basically it just cuts all the data from the page until it sees "My Friend Space", then pulls get_friends_on_page to it. Which im glad get_friends_on_page uses raw content and not a url :) haha #------------------------------------------------------ #myspace_stats will return if there are new posts, #new comments, new pic comments, friend requests, event #invites, blog comments, or blog subscription posts #------------------------------------------------------ sub myspace_stats{ $sender = shift; $account = decode_base64($people_myspace_names{$sender}); $pass = decode_base64($people_myspace_passes{$sender}); print ("$sender has requested MySpace stats\n"); dbg(" Starting MySpace class\n"); my $myspace = WWW::Myspace->new ($account, $pass); dbg(" Getting users homepage\n"); $url = "http://home.myspace.com/index.cfm?fuseaction=user"; print "Getting MySpace status. Please be patient...\n"; $res=$myspace->get_page( $url ); $page = $res->content; my $myspace_id = $myspace->my_friend_id; our $NEW_MESSAGES='<div id="indicatorMail" class="show indicator">'; our $NEW_COMMENTS='<div id="indicatorComments" class="show indicator">'; our $NEW_PIC_COMMENTS='<div id="indicatorImageComments" class="show indicator">'; our $NEW_FRIEND_REQ='<div id="indicatorFriendRequest" class="show indicator">'; our $NEW_EVENT_INV='<div id="indicatorEvents" class="show indicator">'; our $NEW_BLOG_COMMENTS='<div id="indicatorBlogComments" class="show indicator">'; our $NEW_BLOG_SUB_POSTS='<div id="indicatorBlogs" class="show indicator">'; if ( $page =~ /$NEW_MESSAGES/ ) { $results .= "<br><a href=\"http://mail.myspace.com/index.cfm? fuseaction=mail.inbox\">MySpace</a>: <b>You Have New Messages!</b>"; dbg(" New Messages Found\n"); }else{ $results .= "<br><a href=\"http://mail.myspace.com/index.cfm? fuseaction=mail.inbox\">MySpace</a>: 0 new messages"; dbg(" No New Messages\n"); } if ( $page =~ /$NEW_COMMENTS/ ) { $results .= "<br><a href=\"http://comments.myspace.com/index.cfm? fuseaction=user.HomeComments&friendID=".$myspace_id."\">MySpace</a>: <b>You Have New Comments!</b>"; dbg(" New Comments Found\n"); }else{ $results .= "<br><a href=\"http://comments.myspace.com/index.cfm? fuseaction=user.HomeComments&friendID=".$myspace_id."\">MySpace</a>: 0 new comments"; dbg(" No New Comments\n"); } if ( $page =~ /$NEW_PIC_COMMENTS/ ) { $results .= "<br><a href=\"http://comments.myspace.com/index.cfm? fuseaction=user.viewPicture&friendID=".$myspace_id."\">MySpace</a>: <b>You Have New Picture Comments!</b>"; dbg(" New Pic Comments Found\n"); }else{ $results .= "<br><a href=\"http://comments.myspace.com/index.cfm? fuseaction=user.viewPicture&friendID=".$myspace_id."\">MySpace</a>: 0 new pic comments"; dbg(" No New Pic Comments\n"); } . . . . i think you get the idea :) return $results;
Thanks - I'm glad you updated the indicator handling. That MySpace change (which they'd done once before, then changed back) irritated me. Could you also post the values of the $POST_BULLETIN_FORM and $VERIFY_BULLETIN_SENT Regexps? That'd be -really- handy. Thanks, Grant On Wed Feb 22 14:21:26 2006, guest wrote: [...] Show quoted text
> # Try to get the message form > $res = $myspace->get_page( "${POST_BULLETIN_FORM}" );
[...] Show quoted text
> return; > } elsif ( $page =~ /$VERIFY_BULLETIN_SENT/ ) { > print " SUCCESS ON BULLETIN!\n";
From: Plasma2002
On Wed Feb 22 16:14:27 2006, GRANTG wrote: Show quoted text
> Thanks - I'm glad you updated the indicator handling. That MySpace > change (which they'd > done once before, then changed back) irritated me. > > Could you also post the values of the $POST_BULLETIN_FORM and > $VERIFY_BULLETIN_SENT > Regexps? That'd be -really- handy. > > Thanks, > > Grant > > On Wed Feb 22 14:21:26 2006, guest wrote: > [...] >
> > # Try to get the message form > > $res = $myspace->get_page( "${POST_BULLETIN_FORM}" );
> > [...] >
> > return; > > } elsif ( $page =~ /$VERIFY_BULLETIN_SENT/ ) { > > print " SUCCESS ON BULLETIN!\n";
haha, yeah... they changed those indicators 2 days after i posted that code. It pissed me off :) But yea, heres those value..... the varify isnt much of a regexp, just a single phrase it looks for. Im not sure what else it should look for, so thats all i could think of at the moment, haha # The URL of the bulletin posting page. No friend id required our $POST_BULLETIN_FORM="http://bulletin.myspace.com/index.cfm? fuseaction=bulletin.edit"; # What regexp should we look for after sending a message that tells # us the message was sent? our $VERIFY_BULLETIN_SENT = "Bulletin Has Been Posted";
Subject: Re: [rt.cpan.org #17810] Function Ideas and samples
Date: Fri, 24 Feb 2006 11:28:36 -0800
To: bug-WWW-Myspace [...] rt.cpan.org
From: Grant Grueninger <grantg [...] spamarrest.com>
I think "Bulletin has been posted" is probably a pretty good verification. :) Thanks much. -- Grant Grueninger Commercial Systems Corporation http://www.cscorp.com/
On Wed Feb 22 14:21:26 2006, guest wrote: Show quoted text
> Per request, just some sample code i have for those functions i had > described in the forum. > > You might want to download this page so the code will be more
readable Show quoted text
> > > > > note that these were taken straight out of another script which > handled an AIM bot, so each function handled multiple MySpace users > and accounts. Be carefull if your copy and pasting. This is mainly > just here for ideas. > > #------------------------------------------------------ > #post_bulletin posts a bulletin on myspace for the account holder > #------------------------------------------------------ > > > sub post_bulletin{ > > $sender = shift; > $subject = shift; > $message = shift; > $account = decode_base64($people_myspace_names{$sender}); > $pass = decode_base64($people_myspace_passes{$sender}); > > > my ( $submitted, $res, $page ); > > my $myspace = WWW::Myspace->new ($account, $pass); > > $my_id = $myspace->my_friend_id; > print " Users friend id is: $my_id\n"; > if(($my_id) > "1"){ > #its good > }else{ > > #bad username/pass > load_arrays(); > send_message($sender, "It looks like your MySpace > username or password is incorrect. Please go to my page at $bot_page > and update it"); > return; > } > > > > # Try to get the message form > $res = $myspace->get_page( "${POST_BULLETIN_FORM}" ); > > # See if we can post or if there's an error. > if ( $res->is_success ) { > $page = $res->content; > $page =~ s/[ \t\n\r]+/ /g; > } else { > print "there was an html error (1)\n"; > send_message($sender, "There was a MySpace internal > error. It was beyond my control. Sorry :("); > return; > } > > # Take care "\n"s > $message =~ s/\\n/\n/gs; > > # Submit the message > print " Submitting the first form... "; > > $submitted = $myspace->submit_form( $res, > 1, "", > { 'subject' > => "$subject", > 'body' => "$message" > } > ); > > $page = $myspace->{current_page}->content; > $page =~ s/[ \t\n\r]+/ /g; > > print "success!\n"; > > > if ( $res->is_success ) { > $page = $res->content; > $page =~ s/[ \t\n\r]+/ /g; > }else{ > print "there was an html error (2)\n"; > send_message($sender, "There was a MySpace internal > error. It was beyond my control. Sorry :("); > return; > } > > print " Submitting the confirmation form... "; > $confirmed = $myspace->submit_form( $myspace->{current_page}, > 1, "",{} ); > print "success!\n"; > > $page = $myspace->{current_page}->content; > $page =~ s/[ \t\n\r]+/ /g; > > > # Return the result > if (! $confirmed ) { > print " there was an html error (3)\n"; > send_message($sender, "There was a MySpace internal > error. It was beyond my control. Sorry :("); > return; > } elsif ( $page =~ /$VERIFY_BULLETIN_SENT/ ) { > print " SUCCESS ON BULLETIN!\n"; > send_message($sender, "Your bulletin has successfully > been posted :) Remember... you might have to give it up to 5 minutes > before it shows up ;)"); > return; > } else { > print " there was an html error (4)\n"; > send_message($sender, "There was a MySpace internal > error. It was beyond my control. Sorry :("); > return; > } > print "Killing myspace\n\n"; > #kill off the myspace class > $myspace = '' > } > > > > > > > > > > > Heres a littl snippet i use in a function that grabs the friends on > the top 8 list..... > > > > > #lets get the top 8 friends > > > $url = "http://home.myspace.com/index.cfm?fuseaction=user"; > dbg (" Getting top 8 friends for $sender...\n"); > $res=$myspace->get_page( $url ); > $offset = index($res->content,"My Friend Space"); > $content = substr($res->content,$offset) ; > my @mylist = $myspace->get_friends_on_page( $content ); > dbg (" Got top 8 friends\n"); > > #got top 8 > > > > > > basically it just cuts all the data from the page until it sees "My > Friend Space", then pulls get_friends_on_page to it. Which im glad > get_friends_on_page uses raw content and not a url :) haha > > > > > > > > > > > > #------------------------------------------------------ > #myspace_stats will return if there are new posts, > #new comments, new pic comments, friend requests, event > #invites, blog comments, or blog subscription posts > #------------------------------------------------------ > > > sub myspace_stats{ > $sender = shift; > $account = decode_base64($people_myspace_names{$sender}); > $pass = decode_base64($people_myspace_passes{$sender}); > > print ("$sender has requested MySpace stats\n"); > > dbg(" Starting MySpace class\n"); > > my $myspace = WWW::Myspace->new ($account, $pass); > > dbg(" Getting users homepage\n"); > > $url = "http://home.myspace.com/index.cfm?fuseaction=user"; > print "Getting MySpace status. Please be patient...\n"; > $res=$myspace->get_page( $url ); > $page = $res->content; > > > my $myspace_id = $myspace->my_friend_id; > > > our $NEW_MESSAGES='<div id="indicatorMail" class="show > indicator">'; > our $NEW_COMMENTS='<div id="indicatorComments" class="show > indicator">'; > our $NEW_PIC_COMMENTS='<div id="indicatorImageComments" > class="show indicator">'; > our $NEW_FRIEND_REQ='<div id="indicatorFriendRequest" > class="show indicator">'; > our $NEW_EVENT_INV='<div id="indicatorEvents" class="show > indicator">'; > our $NEW_BLOG_COMMENTS='<div id="indicatorBlogComments" > class="show indicator">'; > our $NEW_BLOG_SUB_POSTS='<div id="indicatorBlogs" class="show > indicator">'; > > if ( $page =~ /$NEW_MESSAGES/ ) { > $results .= "<br><a > href=\"http://mail.myspace.com/index.cfm? > fuseaction=mail.inbox\">MySpace</a>: <b>You Have New Messages!</b>"; > dbg(" New Messages Found\n"); > }else{ > $results .= "<br><a > href=\"http://mail.myspace.com/index.cfm? > fuseaction=mail.inbox\">MySpace</a>: 0 new messages"; > dbg(" No New Messages\n"); > } > > > if ( $page =~ /$NEW_COMMENTS/ ) { > $results .= "<br><a > href=\"http://comments.myspace.com/index.cfm? > fuseaction=user.HomeComments&friendID=".$myspace_id."\">MySpace</a>: > <b>You Have New Comments!</b>"; > dbg(" New Comments Found\n"); > }else{ > $results .= "<br><a > href=\"http://comments.myspace.com/index.cfm? > fuseaction=user.HomeComments&friendID=".$myspace_id."\">MySpace</a>:
0 Show quoted text
> new comments"; > dbg(" No New Comments\n"); > } > > if ( $page =~ /$NEW_PIC_COMMENTS/ ) { > $results .= "<br><a > href=\"http://comments.myspace.com/index.cfm? > fuseaction=user.viewPicture&friendID=".$myspace_id."\">MySpace</a>: > <b>You Have New Picture Comments!</b>"; > dbg(" New Pic Comments Found\n"); > }else{ > $results .= "<br><a > href=\"http://comments.myspace.com/index.cfm? > fuseaction=user.viewPicture&friendID=".$myspace_id."\">MySpace</a>:
0 Show quoted text
> new pic comments"; > dbg(" No New Pic Comments\n"); > } > > . > . > . > . > i think you get the idea :) > > > return $results;
post_bulletin and get_notifications methods added