WWW-Myspace
view release on metacpan or search on metacpan
lib/WWW/Myspace.pm view on Meta::CPAN
}
#---------------------------------------------------------------------
# _get_acct()
# Get and store the login and password. We check the user's preference
# file for defaults, then prompt them.
sub _get_acct {
# Initialize
my %prefs = ();
my $ref = "";
my ( $pref, $value, $res );
my $cache_filepath = catfile( $self->cache_dir, $self->cache_file);
# Read what we got last time.
if ( open ( PREFS, "< ", $cache_filepath ) ) {
while (<PREFS>) {
chomp;
( $pref, $value ) = split( ":" );
$prefs{"$pref"} = $value;
}
close PREFS;
}
# Prompt them for current values
unless ( defined $prefs{"email"} ) { $prefs{"email"} = "" }
print "Email [" . $prefs{"email"} . "]: ";
$res = <STDIN>; chomp $res;
if ( $res ) {
$prefs{"email"} = $res;
}
unless ( defined $prefs{"password"} ) { $prefs{"password"} = "" }
print "Password [". $prefs{"password"} . "]: ";
$res = <STDIN>; chomp $res;
if ( $res ) {
$prefs{"password"} = $res;
}
# Make the cache directory if it doesn't exist.
$self->make_cache_dir;
# Store the new values.
open ( PREFS, ">", $cache_filepath ) or croak $!;
print PREFS "email:" . $prefs{"email"} . "\n" .
"password:" . $prefs{"password"} . "\n";
close PREFS;
# Store the account info.
$self->{account_name}=$prefs{"email"};
$self->{password}=$prefs{"password"};
}
#---------------------------------------------------------------------
# _get_friend_id( $homepage )
# This internal method stores our friend ID. We get this from the
# "View Profile" link on our home page (the page we see when we
# click the "Home" link in the top nav bar)
sub _get_friend_id {
( run in 2.358 seconds using v1.01-cache-2.11-cpan-8f98c5d2c55 )