2013-06-01 2 views
1

shell_exec 명령에 몇 가지 변수를 전달하려고하지만 어떤 이유로 PHP 변수의 데이터를 선택하지 않습니다. 제발 도와주세요, 그리고 아래에 내가 무엇을 가지고 있습니다 :변수가있는 PHP 컬

$out = exec('curl -silent https://api.stripe.com/v1/charges -u sk_live_sdfsdfdsfsdfdf: -d "amount=$aaamount" -d currency=usd -d "description=BBB $aaamount" -d "card[number]=$ccnumber" -d "card[exp_month]=$expm" -d "card[exp_year]=$expy" -d "card[cvc]=611"'); 

나는 이것에 얻을 수있는 모든 종류의 도움을 주시면 감사하겠습니다.

+1

작은 따옴표로 묶은 문자열은 변수를 구문 분석하지 않습니다. 큰 따옴표 사용 http://php.net/manual/en/language.types.string.php –

+1

[PHP는 cURL에 바인딩되어 있습니다.] (http://php.net/manual/en/book). curl.php), 맞죠? –

+0

@JonathonReinhart 그게 무슨 뜻입니까 :)? – thevoipman

답변

2

PHP has bindings to cURL, 맞습니까?

게다가 curl 명령 줄을 복사 한 바로 앞 Stripe의 맨 페이지에는 다른 언어 (예 : PHP)로 변경하기위한 드롭 다운 메뉴가 있습니다. 그들은 당신을위한 API를 가지고 있습니다 :

require_once('./lib/Stripe.php'); 
Stripe::setApiKey("sk_test_mkGsLqEW6SLnZa487HYfJVLf"); 

Stripe_Charge::create(array(
    "amount" => 400, 
    "currency" => "usd", 
    "card" => array(
    "number" => "4242424242424242", 
    "exp_month" => 6, 
    "exp_year" => 2014, 
    "cvc" => 314 
), 
    "description" => "Charge for [email protected]") 
); 
+0

현재 코드 구조가 걸리고 컬 출력을 읽습니다 ... – thevoipman

+1

그럼 현재 코드 구조가 분명히 작동하지 않습니다. 맞습니까? 왜 그게 * 바로 * 그런 식으로 API를 사용하지 않습니까? –

+0

큰 따옴표로 작은 따옴표를 대체했습니다. 이제는 작동합니다. 어쨌든 고마워요. – thevoipman