如何在进行请求时在guzzlehttp中传递大于或小于运算符



如何使用guzzle正确发送查询字符串大于运算符的请求?在这里,我想提取日期LastModified大于特定日期的所有记录

$this->client = new Client([
'base_uri'  => $base_url . $version . '/',
'handler'   => $stack,
'auth'      => 'oauth'
]);
$query_string = "?filter=status='active'&dateLastModified>" . "'"$some_date"'" . "&limit=500";
$response = $this->client->get('/students' . $query_string);

我被抛出了下面的错误。注意,大于符号已更改

filter=status='active'&dateLastModified%3E'2021-09-01T16:39:00.000Z'&limit=15000` resulted in a `401 Unauthorized` response: {"errors":[{"codeMajor":"FAILURE","severity":"ERROR","codeMinor":"UNAUTHORIZED","description":"User not authorized."}]}

对大于符号进行编码。(因为您发送了GET,而%3E相当于>(因此,在将其发送到数据库之前,对其进行解码应该可以修复它:https://www.php.net/manual/en/function.urldecode.php

最新更新