Subject: | Help with band show form automation. |
Date: | Sun, 29 Jul 2007 16:52:08 -0700 |
To: | bug-WWW-Myspace [...] rt.cpan.org |
From: | "Ethan Brown" <ethandbrown [...] gmail.com> |
Dear WWW-Myspace maintainers--
First, thank you for your efforts which provide this very useful
module.
I am trying to mechanize the Myspace Band site "Add A Show" form using
your module. I felt that I was making progress, but am getting an
error submitting the form (via submit_form) for the value of the
"State" form element.
I reviewed the form page source and saw that the "State" option value for
"California" is "California|5", however I am getting the error
Illegal value 'California|5' for field 'State' at
/usr/local/share/perl/5.8.7/HTML/Form.pm line 512
when running my test program (see attached).
Any help is appreciated in moving forward with this, including RTFM if
I missed something in the manual.
Thanks,
--Ethan
===========================================================================
#!/usr/bin/perl
##
## Test script for interacting with Myspace. There is currently no function
## in the WWW::Myspace module for adding a show for a band account, but
## there is a very handy method submit_form() for submitting an arbitrary
## Myspace form (by URL). Try using that.
##
## Note: The Myspace account must be a band account for this to have any hope of
## working.
##
use warnings;
use strict;
use Data::Dumper;
use WWW::Myspace;
my $account = 'ethandbrown@gmail.com'; #Your account name (email) goes here.
my $password = 'not_telling'; #Your password goes here.
my $myspace = WWW::Myspace->new (account_name => $account,
password => $password,
human => 1);
unless ( $myspace->logged_in ) { die "Login failed: " . $myspace->error }
## Set up new band show form elements
my $form_url = 'http://editprofile.myspace.com/index.cfm?fuseaction=bandprofile.shows';
my $form_fields = {'sMonth' => 'September',
'sDay' => '6',
'sYear' => '2007',
'sHour' => '20',
'sMin' => '15',
'Venue_Name' => 'Rockin Cafe',
'Address' => '123 Main St.',
'State' => 'California|5',
'Country' => 'US',
'City' => 'Ramona',
'Zip_Code' => '92065',
'Description'=> 'A total rave party!'};
my $button = "formSubmit";
my $submitted =
$myspace->submit_form( {
page => $form_url,
follow => 1,
form_name => 'theForm',
fields_ref => $form_fields,
button => $button
} );
unless ( $submitted )
{
die "Initial form submission failed.";
}
## Submit the confirmation form:
$submitted = $myspace->submit_form({ follow => 1,
form_no => 1
});
unless ( $submitted )
{
die "Form confirmation failed.";
}