# Exemplos de Requisição

### Exemplo em PHP para conexão e consulta de dados via GET

{% code overflow="wrap" lineNumbers="true" %}

```php
<?php

	$cmd='clientes/listar';
	$TOKEN = 'b5f726e203dd31d5ae0a8d3aa4b32782';
	
	$parametros = array(
		'email' => 'zzzzzz@email.com',
		//'nome' => 'lorena',
		//'status'=>'S',//S -> ativo, I -> Inativo, N -> Bloqueado,
		//'registros'=>1,//numero de registros por pagina
		//'pagina'=>2,//pagina atual
	);
			
	//url-ify the data for the GET
	$parametros_string='';
	foreach($parametros as $key=>$value) {
		$parametros_string .= $key.'='.$value.'&';
	}
	rtrim($parametros_string, '&');
	
	$URL = 'https://seusite.com.br/hostmgr/api/'.$cmd.'?'.$parametros_string;
			
	$mediaType = "application/json"; // formato da requisição
	$charSet = "UTF-8";
	$headers = array();
	$headers[] = "Accept: ".$mediaType;
	$headers[] = "Content-Type: ".$mediaType.";charset=".$charSet;
	$headers[] = "hostmgr-token: ".$TOKEN;
	
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $URL);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	//@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	$result = curl_exec($ch);
	
	echo $result;
?>
```

{% endcode %}

### Exemplo em PHP para envio de dados via POST (JSON)

{% code overflow="wrap" lineNumbers="true" %}

```php
<?php

	$cmd='clientes/cadastrar';
	$TOKEN = 'b5f726e203dd31d5ae0a8d3aa4b32782';
	
	$URL = 'https://seusite.com.br/hostmgr/api/'.$cmd;
		
	$post=array(
	
		'nome'=>'Alfredo da Silva',
		'email'=>'alfrado@email.com',
		'cpfCnpj'=>'999.999.999-44',
		'telefone'=>'27999999999',
		'senha'=>'123456',
	);
		
	$data_post = json_encode($post);
	
	$mediaType = "application/json"; // formato da requisição
	$charSet = "UTF-8";
	$headers = array();
	$headers[] = "Accept: ".$mediaType;
	$headers[] = "Content-Type: ".$mediaType.";charset=".$charSet;
	$headers[] = "hostmgr-token: ".$TOKEN;
	
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $URL);
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $data_post);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	//@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	$result = curl_exec($ch);
	
	
	echo $result;

?>
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hostmgr.gitbook.io/desenvolvedores/api/exemplos-de-requisicao.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
