Created
October 2, 2013 20:28
-
-
Save jave/6800037 to your computer and use it in GitHub Desktop.
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/perl | |
#### | |
# Usage examples | |
# | |
# perl addsimple | |
use strict; | |
use warnings; | |
use LWP::UserAgent; | |
use Getopt::Long; | |
use Encode qw/is_utf8 decode/; | |
use POSIX qw(ceil floor); | |
my %opt = (); | |
GetOptions( | |
\%opt, | |
qw/ | |
action=s | |
file=s | |
comment=s | |
name=s | |
original=s | |
categories=s | |
chunk_size=i | |
base_url=s | |
username=s | |
password=s | |
define=s% | |
/ | |
); | |
print "file:" , $opt{file} , "\n"; | |
my %conf = ( | |
base_url => 'http://127.0.0.1:6543/api/piwigo/', | |
); | |
my $ua = LWP::UserAgent->new; | |
$ua->cookie_jar({}); | |
$ua->post( | |
$conf{base_url}.'/ws.php', | |
{ | |
method => 'pwg.session.login', | |
username => 'jave', | |
password => 'notmyrealpwd', | |
} | |
); | |
$ua->post( | |
$conf{base_url}.'/ws.php', | |
{ | |
method => 'pwg.images.addSimple', | |
image => [$opt{file}], | |
category => 1, | |
tags => 'tag1, tag2, another tag', | |
name => $opt{name}, | |
comment => $opt{comment}, | |
author => 'jave', | |
level => 2, | |
}, | |
'Content_Type' => 'form-data', | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment