Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save diego-lipinski-de-castro/bfd42348f6d8dd3b9b357c495db40c09 to your computer and use it in GitHub Desktop.
Save diego-lipinski-de-castro/bfd42348f6d8dd3b9b357c495db40c09 to your computer and use it in GitHub Desktop.
código php
<?php
$mutation = <<<GQL
mutation CreateFolderMutation(
\$folder: FolderInput!
) {
createFolder(
folder: \$folder
) {
id
name
created_at
}
}
GQL;
// Setup cURL
$ch = curl_init($this->config->get('base_url'));
// Set up the payload
$payload = [
'operations' => json_encode([
'query' => $mutation,
'variables' => [
'folder' => [
'name' => $folderName,
],
],
]),
];
// Set cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
// Add headers including the Bearer token
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $this->config->get('token'),
]);
// Execute the cURL session
$response = curl_exec($ch);
// Error handling
if (curl_errno($ch)) {
Log::channel('autentique')->debug('Error:' . curl_error($ch));
return null;
}
// Close cURL session
curl_close($ch);
// Print response from the server
$data = json_decode($response, true);
dd($data);
return $data['data']['createFolder']['id'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment