首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >与-d -u等效的perl curl代码

与-d -u等效的perl curl代码
EN

Stack Overflow用户
提问于 2017-10-27 12:42:20
回答 1查看 419关注 0票数 0

如何在perl WWW:Curl中表示来自命令提示符curl的以下curl代码?

代码语言:javascript
复制
curl https://api.stripe.com/v1/charges \
   -u sk_test_a02zSeLS9cMPlJvu2GkWgSDB: \
   -d amount=1000 \
   -d currency=sgd \
   -d description="Example charge" \
   -d source=tok_2s0QJK6exWUdbSGZb4SpAKep

perl

代码语言:javascript
复制
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;
EN

回答 1

Stack Overflow用户

发布于 2017-10-27 23:25:00

正如您在示例here中所看到的,

代码语言:javascript
复制
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:");
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46967642

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档