Adding queryParams in curl call

using http_build_query()
we can simply pass the parameters  describe in the Api doc.
ex  :  $this->pb->collection('coolCollection')->getFullList(200,['filter'=> $filter])
It can be used for all other function.
This commit is contained in:
BOCKTAELS Hugo
2023-02-22 10:55:46 +01:00
committed by GitHub
parent 2eae1c56ee
commit b0b6fbaaa1

View File

@@ -40,7 +40,8 @@ class Collection
public function getFullList(int $batch = 200, array $queryParams = []) public function getFullList(int $batch = 200, array $queryParams = [])
{ {
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->url . "/api/collections/" . $this->collection . "/records"); $getParams = !empty($queryParams) ? http_build_query($queryParams) : "";
curl_setopt($ch, CURLOPT_URL, $this->url . "/api/collections/" . $this->collection . "/records?".$getParams);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if (self::$token != '') { if (self::$token != '') {
$headers = array( $headers = array(