2017-10-27 2 views
0

어떻게하면 curl 명령 프롬프트의 컬 코드가 perl WWW : Curl에 표시 될 수 있습니까? 사람들은 WWW를 사용하는 이유 :: 쉬운 :: 컬-d -u에 해당하는 perl 컬 코드

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 

펄 당신이 예 here에서 볼 수

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; 
+0

나는 볼 수 없습니다. 나는 그것이 빠르다고 생각한다. 그러나 HTTP보다 훨씬 빠르다. (http://www.martin-evans.me.uk/node/169) 정말로 작고 분명히 실제로는 그렇지 않다. – simbabque

+0

'curl '명령 행 옵션을 번역 할 때, 보통 맨 페이지를 먼저 참조하게됩니다. 지루한 것을 발견하면 [explainhell.com] (https://explainshell.com/explain?cmd=curl+https%3A%2F%2Fapi.stripe.com%2Fv1%2Fcharges+%5C++++-u+sk_test_a02zSeLS9cMPlJvu2GkWgSDB%3A+ % 5C++++ - d + 금액 % 3D1000 + % 5C++++ - d + 통화 % 3Dsgd + % 5C++++ - d + 설명 % 3D % 22 예제 + 청구 % 22 + % 5C++++ - d + 소스 % 3Dtok_2s0QJK6exWUdbSGZb4SpAKep). 이제'-d'와'-u'가 무엇을하는지 알 수 있습니다. 이러한 옵션의 내부 표현이 Perl 바인딩과 함께 사용된다는 것을 배우려면 https://curl.haxx.se/를 참조하십시오. – simbabque

+0

[ "이것은 CPAN에서 일반적으로 사용되는 의미의 쉬운 모듈이 아닙니다.]] (https://metacpan.org/pod/WWW::Curl#WWW::Curl::Easy) – mob

답변

0

,

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:");