Here’s a basic snippet of PHP that lets me execute queries against the v2 API and return the data as JSON. I hope it can provide a leg up and save someone time as they get started.
Just enter your own API key, change the URL to match yours, and put in your query.
$token = '[Personal API Token]';
$tempUrl = "https://api.monday.com/v2/";
$query = ' {
users{
id
email
name
}
}';
$headers = ['Content-Type: application/json', 'User-Agent: [MYTEAM] GraphQL Client', 'Authorization: ' . $token];
$data = @file_get_contents($tempUrl, false, stream_context_create([
'http' => [
'method' => 'POST',
'header' => $headers,
'content' => json_encode(['query' => $query]),
]
]));
$tempContents = json_decode($data, true);