我试图在PHP中执行cURL来执行Stripe Subscription Search。但是我收到了400个错误请求。
下面是我的PHP脚本:
$ch = curl_init();
$created = 'created<' . strtotime('tomorrow');
$next_page=isset($_REQUEST['next_page'])==true?'page='.$_REQUEST['next_page']:'';
$limit = 20;
$curl_url = "https://api.stripe.com/v1/subscriptions/search?".$next_page."&expand[]=total_count&limit=".$limit."&query=status:'active' AND metadata['order_id']:'6735'".'AND '.$created;
//"https://api.stripe.com/v1/subscriptions/search?&expand[]=total_count&limit=20&query=status:'active' AND metadata['order_id']:'6735'AND created<1672272000"
curl_setopt($ch, CURLOPT_URL, $curl_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
$headr = array();
$headr[] = 'Stripe-Version: 2022-11-15';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headr);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, 'XXXX-secret_key_test-XXX');
$response = curl_exec($ch);
curl_close($ch);
1条答案
按热度按时间nlejzf6q1#
我已经解决了这个问题,方法是对查询参数值进行如下编码