0
我想将工作表添加到现有的Google电子表格中,但是速度并不快。以下不适合我。下面的POST请求是否错误?使用Perl发布到Google表格LWP
注意:我的工作表确实是公开的,并已在网络上发布。由于能够成功获取GET请求,因此得到确认。
use strict;
use warnings;
use feature 'say';
use LWP::UserAgent;
my $agent = LWP::UserAgent->new;
my $key = "some key";
my $url = "https://spreadsheets.google.com/feeds/worksheets/$key/public/full"
my $xml = join "\n",
'<entry xmlns="http://www.w3.org/2005/Atom"',
'xmlns:gs="http://schemas.google.com/spreadsheets/2006">',
'<title>Expenses</title>',
'<gs:rowCount>50</gs:rowCount>',
'<gs:colCount>10</gs:colCount>',
'</entry>';
my $response = $agent->post(
$url,
'Content-Type' => 'application/atom+xml',
'Content' => $xml
);
$response->is_success && say "OK";
$response->is_error && say "error";
是真正的代码,你跑了?该代码因运行时异常而失败,因为未定义“$ agent”。你缺少'我的$ agent = LWP :: UserAgent-> new();'总是使用'use strict;使用警告;'!否则,请张贴您实际使用的代码以及'$ response-> as_string'的结果。 (不要忘记在密钥出现在输出中时对其进行混淆) – ikegami
这是来自代码体系的摘录。 “HTTP/1.1 405方法不允许”,然后是一堆东西。嗯,也许邮政不允许在公共纸上? – beasy
你有链接到API的文档? – ikegami