-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.php
More file actions
30 lines (21 loc) · 698 Bytes
/
delete.php
File metadata and controls
30 lines (21 loc) · 698 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
/* Pegando a url do nosso servidor */
$url = 'http://localhost/rest/server.php';
/* Guardando dados em um array */
$data = [
'id' => 9
];
/* Inicia o método cURL pegando a url do servidor como parametro */
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
/* Pega o tipo de requisição, nesse caso estamos formatando para uma requisição customizada */
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: aplication/json'
]);
$resposta = curl_exec($ch);
curl_close($ch);
$dados = json_decode($resposta, true);
echo "<pre>";
print_r($dados);