Dec 5, 2022
0
Level 1
let me explain, how to set pagination
the data from external API using cURL get request with domain and fields.how to set pagination with offset.
public function search_with_date_range($date_from,$date_to)
{
$customer = Customer::find(Auth::id());
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $this->api_url.'/apilink/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_POSTFIELDS => array(
'db' => 'name',
'domain' => '[(\'id\',\'=\')]',
'fields' => '[\'name\']',
'order' => 'id desc'
),
CURLOPT_HTTPHEADER => array(
'access-token: '.Auth::user()->access_token,
),
));
$response = curl_exec($curl);
$httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
$search_result = json_decode($response);
return $search_result;
Please or to participate in this conversation.