-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuncao_de_integracao.php
51 lines (48 loc) · 1.69 KB
/
funcao_de_integracao.php
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Inicio da integração com o vestibularonline.com.br
public function enviarDadosAPIVestibular($cadastro){
$url = 'http://homologacao-integracao.vestibularonline.com.br/api/Vestibular/CadastrarDadosInscricaoCandidato/?token=';
$ch = curl_init($url);
$data = (object)array(
'cadastro_candidato' => [
'dados' => [
'Id' => $cadastro->id,
'NomeCompleto' => $cadastro->nome,
'Email' => $cadastro->email,
'CPF' => $cadastro->cpf,
'TelefoneCelular' => $cadastro->telefone
]
],
'inscricao_candidato' => [
'dados' => [
'LeadReferencia' =>[
'Id' => $cadastro->id,
'Nome' => $cadastro->nome
],
'NumeroInscricao' => $cadastro->id,
'DataProva' => $cadastro->data_agendada,
'PeriodoLevito' => '2020-2'
]
]
);
$options = array(
'http' => array(
'method' => 'POST',
'content' => json_encode( $data ),
'header'=> "Content-Type: application/json\r\n" .
"Accept: application/json\r\n"
)
);
$payload = json_encode(array("dados" => $data));
//codificando o json, padrão
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
//colocando que o tipo de paramtro é um json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
//Retorna a resposta em vez de emitir
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//execução da resposta
$result = curl_exec($ch);
//var_dump($result);
//fechando a conexão.
curl_close($ch);
}
// Fim da integração com o vestibularonline.com.br