Created
October 19, 2010 07:52
-
-
Save ryu22e/633806 to your computer and use it in GitHub Desktop.
StatusNetにpostするPerlスクリプトのサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use utf8; | |
use HTTP::Request::Common; | |
use LWP::UserAgent; | |
# TODO ここにログインIDを入れる | |
use constant LOGIN_ID => ''; | |
# TODO ここにパスワードを入れる | |
use constant PASSWORD => ''; | |
# TODO ここにStasutNetのURLを入れる | |
use constant STATUSNET_URL => ''; | |
use constant API_PATH => '/api/statuses/update.xml'; | |
use constant MESSAGE => 'This is example.'; | |
my $url = STATUSNET_URL . API_PATH; | |
my $req = POST( $url, [ status => MESSAGE ] ); | |
$req->authorization_basic( LOGIN_ID, PASSWORD ); | |
my $ua = LWP::UserAgent->new; | |
my $res = $ua->request($req); | |
if ( $res->is_success ) { | |
print "Message is posted!\n"; | |
} | |
else { | |
print "Failed to post.\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment