幫助,我試圖在WordPress的博客中創建一個新的職位,使用以下perl腳本在XMLRPC上使用metaweblogAPI自定義字段,但似乎有自定義字段的問題。只有第二個自定義字段(寬度)似乎過去了。無法獲得正確發佈的「高度」。當我添加另一個字段時,出現「匿名散列中的奇數元素」錯誤。這應該是簡單的 - 有人會善意地檢查我的語法嗎?謝謝。爲什麼我在Perl中獲得「匿名散列中的奇數個元素」警告?
#!/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;
看到這個複製hashref的答案http://stackoverflow.com/a/7083603/2015531 – ophidion 2013-08-27 09:06:21