ilovechristy has asked for the wisdom of the Perl Monks concerning the following question:
Help, I'm trying to create a new post in my wordpress blog with custom fields using the following perl script using metaweblogAPI over XMLRPC, but there seems to be an issue with the custom fields. Only the second custom field (width) ever seems to get posted. Can't get the "height" to publish properly. When I add another field, I get the "Odd number of elements in anonymous hash" error. This has got to be something simple - would someone kindly sanity check my syntax? Thanks.
#!/usr/bin/perl -w use strict; use RPC::XML::Client; use Data::Dumper; my $cli=RPC::XML::Client->new('http://www.sitename.com/wp/xmlrpc.php') +; my $appkey="perl"; # doesn't matter my $blogid=1; # doesn't matter (except blogfarm) my $username="Jim"; my $passwd='_____'; my $text=<<'END'; This is the post content... You can also include html tags... See you! END my $publish=0; # set to 1 to publish, 0 to put post in drafts my $resp=$cli->send_request('metaWeblog.newPost', $blogid, $username, $passwd, { 'title' => "this is doodoo", 'description' => $text, 'custom_fields' => { { "key" => "height", "value" => 500 }, { "key" => "width", "value" => 750 } }, }, $publish); exit 0;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hash (within an array?) issue
by jwkrahn (Abbot) on Aug 30, 2009 at 01:04 UTC | |
by ilovechristy (Novice) on Aug 30, 2009 at 03:09 UTC | |
|
Re: hash (within an array?) issue
by stevieb (Canon) on Aug 30, 2009 at 01:11 UTC |