Repository navigation
Expand file tree
/
Copy pathsentimonitor-exemplo-authors.php
More file actions
89 lines (81 loc) · 2.67 KB
/
Copy pathsentimonitor-exemplo-authors.php
File metadata and controls
89 lines (81 loc) · 2.67 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
// Para mais detalhes, ver documentação do Sentimonitor em: https://www.sentimonitor.com/docs/pt-br/dev/
/*
Lista de filtros possíveis
Ver descrição completa na do Sentimonitor
$aFiltros = array (
"monitorings" => "", // obrigatório
"start" => "", // obrigatório
"end" => "", // obrigatório
"sources" => "",
"viewSource" => "",
"query" => "",
"authorName" => "",
"authorAbout" => "",
"sentiments" => "",
"languages" => "",
"tags" => "",
"ignoreTags" => "",
"tagExpression" => "",
"authors" => "",
"authorTags" => "",
"onlyVerifiedAuthors" => "",
"onlyWithPersonalUrl" => "",
"contributors" => ""
);
*/
$aFiltros = array (
"monitorings" => "2576,4954", // *obrigatório* - ver o método "monitorings" na documentação - exemplo de implementação em "sentimonitor-exemplo-monitorings.php"
"start" => "2018-12-30 00:00", // *obrigatório* - data inicial da pesquisa
"end" => "2018-12-30 13:15" // *obrigatório* - data final da pesquisa
);
$sKey = "<sua-api-key>"; // Fornecida pelo suporte do Sentimonitor
$sEmail = "<seu-e-mail>"; // E-mail do seu login
$sAuth = base64_encode($sEmail . ":" . $sKey); // Ver detalhes sobre a autenticação na documentação
$aHeader = array("Authorization: Basic " . $sAuth);
$oComm = curl_init("https://app.sentimonitor.com/api/4.0/authors?" . http_build_query($aFiltros));
curl_setopt($oComm, CURLOPT_HTTPHEADER, $aHeader);
curl_setopt($oComm, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($oComm, CURLOPT_TIMEOUT, 30);
curl_setopt($oComm, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($oComm, CURLOPT_HTTPGET, 1);
$sRetorno = curl_exec($oComm);
$oRetorno = json_decode($sRetorno);
if (empty($oRetorno) || isset($oRetorno->errors))
die("<b>Erro:</b>" . $oRetorno->errors[0]->message);
?>
<html>
<head>
<title>Exemplo de Integração com Sentimonitor - Author</title>
</head>
<body>
<b>Resultados retornados:</b>
<br><br>
<table>
<tr>
<th>Author</th>
<th>Dados do author</th>
</tr>
<?php
foreach ($oRetorno->data as $iIndex => $oData) {
?>
<tr>
<td>
<?php
echo $iIndex + 1;
?>
</td>
<td>
<?php
print_r($oData);
?>
</td>
</tr>
<tr><td> </td></tr>
<tr><td> </td></tr>
<?php
}
?>
</table>
</body>
</html>