如何在perl WWW:Curl中表示来自命令提示符curl的以下curl代码?
curl https://api.stripe.com/v1/charges \
-u sk_test_a02zSeLS9cMPlJvu2GkWgSDB: \
-d amount=1000 \
-d currency=sgd \
-d description="Example charge" \
-d source=tok_2s0QJK6exWUdbSGZb4SpAKepperl
use WWW::Curl::Easy;
my $curl = WWW::Curl::Easy->new;
$curl->setopt(CURLOPT_HEADER,1);
$curl->setopt(CURLOPT_URL, 'https://api.stripe.com/v1/charges');
# A filehandle, reference to a scalar or reference to a typeglob can be used here.
my $response_body;
$curl->setopt(CURLOPT_WRITEDATA,\$response_body);
# Starts the actual request
my $retcode = $curl->perform;发布于 2017-10-27 23:25:00
正如您在示例here中所看到的,
use WWW::Curl::Form;
my $curlf = WWW::Curl::Form->new;
$curlf->formadd("amount", "1000");
$curlf->formadd("currency", "sgd");
$curlf->formadd("description", "Example charge");
$curlf->formadd("source", "tok_2s0QJK6exWUdbSGZb4SpAKep");
$curl->setopt(CURLOPT_HTTPPOST, $curlf);
$curl->setopt(CURLOPT_USERPWD,"sk_test_a02zSeLS9cMPlJvu2GkWgSDB:");https://stackoverflow.com/questions/46967642
复制相似问题