b660745b
Alex Savenko
git bug
|
1
2
3
4
5
6
7
8
9
10
11
12
|
<?php
/**
* Created by PhpStorm.
* User: Alex Savenko
* Date: 22.02.2017
* Time: 20:18
*/
namespace App\Controllers;
|
903ac393
Alex Savenko
ap testing
|
13
|
use allpositions\api\Client;
|
a84f80c9
Alex Savenko
ap
|
14
|
use Phalcon\Exception;
|
b660745b
Alex Savenko
git bug
|
15
|
use PhalconRest\Mvc\Controllers\CrudResourceController;
|
b660745b
Alex Savenko
git bug
|
16
17
18
19
20
|
class AllPositionController extends CrudResourceController
{
const API_KEY = '150bb253651622507341cd7845f5b9d2';
|
4d5d538f
Alex Savenko
AP php docs
|
21
22
23
24
25
|
/**
* Данные о проекте
*
* @return array [url, cy, pr, yaca, dmoz, yahoo]
*/
|
37701e29
Alex Savenko
ap testing
|
26
|
public function projectAction() {
|
b660745b
Alex Savenko
git bug
|
27
|
|
37701e29
Alex Savenko
ap testing
|
28
29
|
/** user params **/
$project = $this->request->get('project') ?? 418068;
|
061c2fe1
Alex Savenko
ap
|
30
|
|
37701e29
Alex Savenko
ap testing
|
31
|
$APObj = new Client(self::API_KEY);
|
061c2fe1
Alex Savenko
ap
|
32
|
|
37701e29
Alex Savenko
ap testing
|
33
|
$project_info = $APObj->getProject($project);
|
061c2fe1
Alex Savenko
ap
|
34
|
|
37701e29
Alex Savenko
ap testing
|
35
|
return $project_info;
|
73c25dbe
Alex Savenko
ap
|
36
|
|
37701e29
Alex Savenko
ap testing
|
37
|
}
|
b660745b
Alex Savenko
git bug
|
38
|
|
4d5d538f
Alex Savenko
AP php docs
|
39
40
41
42
43
|
/**
* Список проектов пользователя
*
* @return array[] [id_project, id_group, url, cy, pr]
*/
|
37701e29
Alex Savenko
ap testing
|
44
45
|
public function projectsAction() {
|
34cfbfc0
Alex Savenko
allposition docs
|
46
47
48
|
/** user params **/
$id_group = $this->request->get('id_group') ?? null;
|
37701e29
Alex Savenko
ap testing
|
49
50
|
$APObj = new Client(self::API_KEY);
|
34cfbfc0
Alex Savenko
allposition docs
|
51
|
$projects_info = $APObj->getProjects($id_group);
|
37701e29
Alex Savenko
ap testing
|
52
53
54
55
56
|
return $projects_info;
}
|
4d5d538f
Alex Savenko
AP php docs
|
57
58
59
60
61
|
/**
* Список групп проектов
*
* @return array[] [id_group, group]
*/
|
e83a94b3
Alex Savenko
docs + ap
|
62
63
64
65
66
67
68
69
70
71
|
public function projectsGroupAction() {
$APObj = new Client(self::API_KEY);
$projects_group = $APObj->getProjectsGroup();
return $projects_group;
}
|
4d5d538f
Alex Savenko
AP php docs
|
72
73
74
75
76
|
/**
* Список запросов, по которым определяется позиция сайта
*
* @return array[] [id_query, id_group, query, freq, url]
*/
|
37701e29
Alex Savenko
ap testing
|
77
78
79
80
|
public function queriesAction() {
/** user params **/
$project = $this->request->get('project') ?? 418068;
|
34cfbfc0
Alex Savenko
allposition docs
|
81
|
$id_group = $this->request->get('id_group') ?? null;
|
37701e29
Alex Savenko
ap testing
|
82
83
84
|
$APObj = new Client(self::API_KEY);
|
5824f1c9
Alex Savenko
add get_report_da...
|
85
|
$queries_info = $APObj->getQueries($project, $id_group);
|
37701e29
Alex Savenko
ap testing
|
86
|
|
5824f1c9
Alex Savenko
add get_report_da...
|
87
|
return $queries_info;
|
37701e29
Alex Savenko
ap testing
|
88
89
90
|
}
|
4d5d538f
Alex Savenko
AP php docs
|
91
92
93
94
95
|
/**
* Список групп запросов
*
* @return array[] [id_group, group]
*/
|
e83a94b3
Alex Savenko
docs + ap
|
96
97
98
99
100
101
102
103
104
105
106
107
108
|
public function queriesGroupAction() {
/** user params **/
$project = $this->request->get('project') ?? 418068;
$APObj = new Client(self::API_KEY);
$queries_group = $APObj->getQueriesGroup($project);
return $queries_group;
}
|
4d5d538f
Alex Savenko
AP php docs
|
109
110
111
112
113
114
115
116
117
118
|
/**
* Отчет по позициям сайта
*
* @return array [
* count, top3, top10, top30, down, up, date, prev_date,
* sengines[id_se, name_se, name_region][],
* queries[id_query, query, wordstat][],
* positions[position, prev_position, change_position, url][]
* ]
*/
|
f0d4c855
Alex Savenko
ap testing
|
119
120
121
122
123
|
public function reportAction() {
/** user params **/
$project = $this->request->get('project') ?? 418068;
$date = $this->request->get('date') ?? '2017-01-31';
|
34cfbfc0
Alex Savenko
allposition docs
|
124
|
$prev_date = $this->request->get('prev_date') ?? '2017-01-01';
|
f0d4c855
Alex Savenko
ap testing
|
125
126
127
|
$APObj = new Client(self::API_KEY);
|
5824f1c9
Alex Savenko
add get_report_da...
|
128
|
$report_info = $APObj->getReport($project, $date, $prev_date);
|
f0d4c855
Alex Savenko
ap testing
|
129
|
|
5824f1c9
Alex Savenko
add get_report_da...
|
130
|
return $report_info;
|
f0d4c855
Alex Savenko
ap testing
|
131
132
133
|
}
|
4d5d538f
Alex Savenko
AP php docs
|
134
135
136
137
138
|
/**
* Данные о видимости сайта за указанный период
*
* @return array [id_project, begin_date, end_date, id_se]
*/
|
37701e29
Alex Savenko
ap testing
|
139
140
141
142
143
144
|
public function visibilityAction() {
/** user params **/
$project = $this->request->get('project') ?? 418068;
$get_start_date = $this->request->get('start') ?? '30daysAgo';
$get_end_date = $this->request->get('end') ?? 'today';
|
34cfbfc0
Alex Savenko
allposition docs
|
145
|
$id_se = $this->request->get('id_se') ?? 0;
|
37701e29
Alex Savenko
ap testing
|
146
147
148
|
$APObj = new Client(self::API_KEY);
|
5824f1c9
Alex Savenko
add get_report_da...
|
149
|
$visibility_info = $APObj->getVisibility($project, $get_start_date, $get_end_date, $id_se);
|
37701e29
Alex Savenko
ap testing
|
150
|
|
5824f1c9
Alex Savenko
add get_report_da...
|
151
152
153
154
|
return $visibility_info;
}
|
4d5d538f
Alex Savenko
AP php docs
|
155
156
157
158
159
|
/**
* Список дат, когда обновлялись позиции сайта
*
* @return array
*/
|
5824f1c9
Alex Savenko
add get_report_da...
|
160
161
162
163
164
165
166
167
168
169
|
public function reportDatesAction() {
/** user params **/
$project = $this->request->get('project') ?? 418068;
$APObj = new Client(self::API_KEY);
$report_info = $APObj->getReportDates($project);
return $report_info;
|
b660745b
Alex Savenko
git bug
|
170
171
172
|
}
|
33c32777
Alex Savenko
ap testing
|
173
|
}
|