这是来自 Stripe API curl 方法的 curl 请求:
curl https://api.stripe.com/v1/accounts \
-u sk_test_**********: \
-d managed=false \
-d country=US \
-d email="bob@example.com"
现在我有这个 unirest 代码:
<?php Unirest\Request::auth(Config::get("stripe.secret.api_key"), '');
$headers = array(
"Content-Type" => "application/json"
);
$body = array(
"managed" => $_managed,
"country" => $_country,
"email" => $_email,
);
$response = Unirest\Request::post("https://api.stripe.com/v1/accounts", $headers, $body);
return array(
'status' => 'success',
'message' => $response
); ?>
Stripe 返回方法错误。我认为它是 curl 中的 -u
参数。
最佳答案
我对 Unirest
了解不多。当您遇到 -u
header 问题时,您可以在 url 中使用授权参数,如下所示。
https://sk_test_RxRTXF1CDHuRw3ZUdynxnG6P:@api.stripe.com/v1/accounts
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
关于php - 将 Curl 转换为 Unirest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35312625/