updated git and svn scripts
[xrzperl.git] / sina.login
blob7456422cc101b43834a5b9095234f35090405e43
1 #!/usr/bin/perl -w
2 # $Id$
3 use strict;
4 require v5.10.0;
5 our $VERSION = 'v0.1';
7 BEGIN
9 our $PROGRAM_DIR = $ENV{XR_PERL_SOURCE_DIR};
10 unless($PROGRAM_DIR) {
11 $PROGRAM_DIR = $0;
12 $PROGRAM_DIR =~ s/[^\/\\]+$//;
13 $PROGRAM_DIR =~ s/\/+$//;
14 $PROGRAM_DIR = "." unless($PROGRAM_DIR);
16 unshift @INC,
17 map "$PROGRAM_DIR/$_",qw{modules lib ../modules ..lib};
20 my %OPTS;
21 my @OPTIONS = qw/help|h|? version|ver edit-me manual|man/;
23 if(@ARGV)
25 require Getopt::Long;
26 require MyPlace::Usage;
27 Getopt::Long::GetOptions(\%OPTS,@OPTIONS);
28 MyPlace::Usage::Process(\%OPTS,$VERSION);
31 my($user,$pass) = @ARGV;
32 if(!$user) {
33 print STDERR "Login Id:";
34 $user= readline(*STDIN);
35 print STDERR "\n";
36 die("Invalid Login Id") unless($user);
38 if(!$pass) {
39 print STDERR "Password:";
40 $pass= readline(*STDIN);
41 print STDERR "\n";
42 die("Invalid password") unless($pass);
44 use MyPlace::Sina;
45 my $sina = MyPlace::Sina->new();
46 print STDERR "[$user] Logining into sina.com.cn ...\n";
47 my ($ex,$data) = $sina->login($user,$pass,"http://t.sina.com.cn");
48 if($data =~ m/"result":true/) {
49 print STDERR "[OK]\n";
50 exit 0;
52 else {
53 print STDERR "[Failed]\n";
54 exit 1;
58 __END__
60 =pod
62 =head1 NAME
64 sina.login - PERL script
66 =head1 SYNOPSIS
68 sina.login [options] ...
70 =head1 OPTIONS
72 =over 12
74 =item B<--version>
76 Print version infomation.
78 =item B<-h>,B<--help>
80 Print a brief help message and exits.
82 =item B<--manual>,B<--man>
84 View application manual
86 =item B<--edit-me>
88 Invoke 'editor' against the source
90 =back
92 =head1 DESCRIPTION
94 ___DESC___
96 =head1 CHANGELOG
98 2010-11-09 22:39 xiaoranzzz <xiaoranzzz@myplace.hell>
100 * file created.
102 =head1 AUTHOR
104 xiaoranzzz <xiaoranzzz@myplace.hell>
106 =cut
108 # vim:filetype=perl