代码如下:尝试了几种不同的参数。任何意见都很好。
$endpoint = "https://api.stripe.com/v1/payments";
$params = array('limit' => '100', 'created[gte]' => '1627831313');
$url = $endpoint . '?' . http_build_query($params);
$ch = curl_init();
$headr = array();
$headr[] = 'Content-length: 0';
$headr[] = 'Content-type: application/json';
$headr[] = 'Authorization: Bearer [OUR STRIPE KEY]';
curl_setopt($ch, CURLOPT_HTTPHEADER,$headr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$url);
$result=curl_exec($ch);
curl_close($ch);
下面是我们得到的响应:
curl https://api.stripe.com/v1/payments -u [OUR STRIPE KEY]: -d limit=3 -d created=1627831313 -G
{
"error": {
"code": "parameter_unknown",
"doc_url": "https://stripe.com/docs/error-codes/parameter-unknown",
"message": "Received unknown parameter: created",
"param": "created",
"type": "invalid_request_error"
}
}
愚蠢的问题,你只是忘记把$result
写在某个地方看吗?您得到的是空响应,还是遇到了错误?
我认为这是因为您调用了/payments
端点,这不是您想要的。将路径更改为/payment_intents
(API ref)。要获得客户、订阅和发票,您需要分别对这些端点进行调用。