Hey @Hilary - we have a quickstart tutorial for using PHP to make API queries.
One thing I will recommend from seeing previous users use PHP for this - I would recommend maintaining any variables within the $vars
object so that json_decode
will run on them. You can see an example of what I mean on the last example in the tutorial page:
<?php
$query = 'mutation ($myItemName: String!, $columnVals: JSON!) { create_item (board_id:YOUR_BOARD_ID, item_name:$myItemName, column_values:$columnVals) { id } }';
$vars = ['myItemName' => 'Hello world!',
'columnVals' => json_encode([
'status' => ['label' => 'Done'],
'date4' => ['date' => '1993-08-27']
])];
$data = @file_get_contents($apiUrl, false, stream_context_create([
'http' => [
'method' => 'POST',
'header' => $headers,
'content' => json_encode(['query' => $query, 'variables' => $vars]),
]
]));
$responseContent = json_decode($data, true);
echo json_encode($responseContent);
?>
-Daniel