#!/fellow/monks.pl I found the following code on http://timjoh.com/perl-post-automatically-to-wordpress-blog-with-wp-posterpl/ which will allow a user to publish information into a Wordpress blog. From what I can tell, the code is fine. The problem is when the the authentication bit starts, Wordpress issues a cookie, or at least tries to.

The problem is Wordpress comes back saying the browser doesn't support cookies.

Correct me if I'm wrong, but $ua->cookie_jar( {} ); is the cookie jar, right? Why doesn't LWP tell Wordpress the right thing? Is it something else?

use strict; use LWP::UserAgent; # ====== Parameters to change =============== my $burl = 'http://www.example.com/'; # don't forget the trailing slas +h my ( $usr, $pwd, $uid ) = ( 'admin', 'secret', 1 ); # uid=1 if you are + the initial administrator my $title = "Wordpress Post title"; my $body = "Wordpress body text"; # =========================================== # ua my $ua = LWP::UserAgent->new; #$ua->agent('wp-poster'); $ua->cookie_jar({}); # login print "Login : "; my $req = HTTP::Request->new( POST => $burl . 'wp-login.php' ); $req->content_type('application/x-www-form-urlencoded'); $req->content( sprintf('log=%s&pwd=%s&wp-submit=1&redirect_to=wp-admin +/post-new.php',$usr,$pwd) ); my $res = $ua->request( $req ); if ( $res->is_success ) { print "SUCCESS!!\n"; print $res->content; ##### Yes, we're successfull, but Wordpress says cookies aren' +t enabled... Huh ?? } else { print "FAILURE!!\n"; &debug($res, 0); exit(1); }

Thanks!

Massyn

In reply to LWP ignoring cookies?? by Massyn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.