I have this graphql request string:
$data_string = '{"query":"query {\n search(input: {\n projectId: \"'.$project_id.'\",\n search: \"'
.$expr.'\",\n limit: '.$page_size.',\n offset: '.$offset.'\n }) {\n total\n result\n }\n}"}';
And I'd like to to next thing:
$data_string = '{"query":"query {
search(input: {
projectId: \"'.$project_id.'\",
search: \"'.$expr.'\",
limit: '.$page_size.',
offset: '.$offset.'
}) {
total
result
}
}"}';
But, for some reason, it doesn't work.
Here's how I make request:
$ch = curl_init($search_api_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
P.S. I'm new in PHP