PHP Curl with Variables


PHP Curl with Variables

我试图传递一些变量到shell_exec命令,但由于某种原因,它没有在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"');

你知道PHP有cURL绑定,对吧?

此外,在Stripe的首页,就在你可能复制curl命令行的地方,有一个下拉菜单,可以更改为其他语言,即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 test@example.com")
);