form method post accept-charset utf-8 label Запрос label input type te

 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
<form method="post" accept-charset="utf-8">
<label>Запрос</label><input type="text" name="q" value="">
<br>
<label>Регион</label><input type="text" name="r" value="255">
<br>
<label>Лимит</label><input type="text" name="r" value="10">
<input type="submit">
</form>
<?
if (isset($_POST['q'])) {
$params = array(
'query' => htmlspecialchars($_POST['q']),
'region' => intval($_POST['r']),
'limit' => intval($_POST['r'])
);
$ch = curl_init('http://api.pr-cy.ru/realtime/yandex/serp?' . http_build_query($params));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Api-Key: ВАШ_КЛЮЧ'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$json = json_decode(curl_exec($ch));
echo '<pre>';
print_r($json);
}
?>