Skip to content

Instantly share code, notes, and snippets.

@ichigotake
Created June 2, 2012 09:16
Show Gist options
  • Select an option

  • Save ichigotake/2857485 to your computer and use it in GitHub Desktop.

Select an option

Save ichigotake/2857485 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Encode qw/encode_utf8/;
use HTTP::Request::Common;
use LWP::UserAgent;
use Data::Dumper;
my $ua = LWP::UserAgent->new;
my $text = <<TEXT;
#public
Hello world!
#test1 #test2
TEXT
my $req = POST('http://localhost.net:3000/api/post', [
text => encode_utf8( $text ),
token => '0000000000000000000000000000000000000000000000000000000000000000',
]);
my $res = $ua->request($req);
if ( $res->status_line == 200 ) {
print "success!";
}
else {
print "faild post: ". $res->status_line;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment