搜尋

首頁  >  問答  >  主體

Stripe 搜尋 API:請求錯誤 - 400 錯誤請求

<p>我正在嘗試在 PHP 中執行 cURL 來執行 Stripe 訂閱搜尋。但我收到 400 Bad Request。 </p> <p>這是我的 PHP 腳本:</p> <pre class="brush:php;toolbar:false;">$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);</pre></p>
P粉268654873P粉268654873480 天前553

全部回覆(1)我來回復

  • P粉493313067

    P粉4933130672023-09-04 11:38:55

    我透過對查詢參數值進行編碼解決了這個問題

    $curl_url = "https://api.stripe.com/v1/subscriptions/search?".$next_page."&expand[]=total_count&limit=".$limit
    ."&query=".urlencode($status.' AND '.$created)`

    回覆
    0
  • 取消回覆