package IIbaeecde032f749e1cf53bc335cb08cc3::mod_custom; use strict; use LWP::UserAgent; use II8b55f24974af3d53369c3d9cea404f55::filters::html2text; sub publish { my $class = shift; my ($blog, $subject, $message, $catz, $tags) = @_; my $ua = LWP::UserAgent->new; $ua->timeout(20); $ua->env_proxy; $ua->cookie_jar( {} ); my $data; my @entries = map { split('=', $_, 2) } grep { length($_) && ! /^\#/ } split(/\r?\n/, $blog->{login_params}); for (my $i = 0; $i < @entries; $i += 2) { my $value = $entries[$i + 1]; for ($value) { s/\#\{username\}/$blog->{username}/g; s/\#\{password\}/$blog->{password}/g; } $data->{$entries[$i]} = $value; } my $response = $ua->post($blog->{login_url}, $data); return "Error logging in to $blog->{login_url}: " . $response->status_line unless $response->is_success; warn "BLOGPUB DEBUG HELPER: logging in to $blog->{login_url} response content: " . $response->content; $message = II8b55f24974af3d53369c3d9cea404f55::filters::html2text::html2text($message) if $blog->{format}; @entries = map { split('=', $_, 2) } grep { length($_) && ! /^\#/ } split(/\r?\n/, $blog->{pub_params}); for (my $i = 0; $i < @entries; $i += 2) { my $value = $entries[$i + 1]; for ($value) { s/\#\{subject\}/$subject/g; s/\#\{message\}/$message/g; s/\#\{categories\}/$catz/g; s/\#\{tags\}/$tags/g; } $data->{$entries[$i]} = $value; } $response = $ua->post($blog->{pub_url}, $data); return "Error publishing to $blog->{pub_url}: " . $response->status_line unless $response->is_success; warn "BLOGPUB DEBUG HELPER: publishing to $blog->{login_url} response content: " . $response->content; return; } 1; 