1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
bitrixseo.php
См. документацию.
1<?php
2
3use \Bitrix\Main\Localization\Loc;
4
5Loc::loadMessages(__FILE__);
6
7if (!defined("BITRIX_CLOUD_ADV_URL"))
8{
9 $domain = (new \Bitrix\Main\License\UrlProvider())->getTechDomain();
10 $cloudAdvUrl = 'https://cloud-adv.' . $domain;
11
12 define("BITRIX_CLOUD_ADV_URL", $cloudAdvUrl);
13}
14
15if (!defined('BITRIXSEO_URL'))
16{
17 define('BITRIXSEO_URL', BITRIX_CLOUD_ADV_URL);
18}
19
21{
22 const SERVICE_ID = "bitrixseo";
23
24 const URL = BITRIXSEO_URL;
25
26 protected string $proxyUrl = BITRIXSEO_URL;
27
29 protected $transport = null;
30
31 protected $scope = array(
32 'seo'
33 );
34
35 public function __construct($appID = false, $appSecret = false, $code = false)
36 {
37 if($appID === false)
38 {
39 $appID = trim(CSocServAuth::GetOption("bitrixseo_id"));
40 }
41
42 if($appSecret === false)
43 {
44 $appSecret = trim(CSocServAuth::GetOption("bitrixseo_secret"));
45 }
46
47 parent::__construct($appID, $appSecret, $code);
48 }
49
53 public function getTransport()
54 {
55 if($this->transport === null)
56 {
57 $this->transport = new CBitrixSeoTransport($this->getAppID(), $this->getAppSecret(), $this->getProxyUrl());
58 }
59
60 return $this->transport;
61 }
62
63 public function getClientInfo()
64 {
65 if($this->getAppID() && $this->getAppSecret())
66 {
67 $res = $this->getTransport()->getClientInfo();
68
69 if(!isset($res['error']))
70 {
71 return $res['result'];
72 }
73 }
74
75 return false;
76 }
77
78 public function getClientList()
79 {
80 if($this->getAppID() && $this->getAppSecret())
81 {
82 $res = $this->getTransport()->getClientList();
83
84 if(isset($res['result']) && !isset($res['error']))
85 {
86 return $res['result'];
87 }
88 }
89
90 return false;
91 }
92
93 public function clearClientAuth($engine, $clientId = null)
94 {
95 if($this->getAppID() && $this->getAppSecret() && $engine)
96 {
97 $res = $this->getTransport()->clearClientAuth($engine, $clientId);
98
99 if(!isset($res['error']))
100 {
101 return $res['result'];
102 }
103 }
104
105 return false;
106 }
107
108 public function addCampaign($engine, array $campaignParams)
109 {
110 if($this->getAppID() && $this->getAppSecret() && $engine)
111 {
112 $res = $this->getTransport()->call(
114 array(
115 "engine" => $engine,
116 "campaign" => $campaignParams
117 )
118 );
119
120 if(!isset($res['error']))
121 {
122 return $res['result'];
123 }
124 else
125 {
126 return $res;
127 }
128 }
129
130 return false;
131 }
132
133 public function updateCampaign($engine, array $campaignParams)
134 {
135 if($this->getAppID() && $this->getAppSecret() && $engine)
136 {
137 $res = $this->getTransport()->call(
139 array(
140 "engine" => $engine,
141 "campaign" => $campaignParams
142 )
143 );
144
145 if(!isset($res['error']))
146 {
147 return $res['result'];
148 }
149 else
150 {
151 return $res;
152 }
153 }
154
155 return false;
156 }
157
158 public function getCampaign($engine, array $campaignParams)
159 {
160 if($this->getAppID() && $this->getAppSecret() && $engine)
161 {
162 $res = $this->getTransport()->call(
164 array(
165 "engine" => $engine,
166 "campaign" => $campaignParams
167 )
168 );
169
170 if(!isset($res['error']))
171 {
172 return $res['result'];
173 }
174 else
175 {
176 return $res;
177 }
178 }
179
180 return false;
181 }
182
183 public function getCampaignList($engine)
184 {
185 if($this->getAppID() && $this->getAppSecret() && $engine)
186 {
188 'engine' => $engine,
189 ));
190
191 if(!isset($res['error']))
192 {
193 return $res['result'];
194 }
195 else
196 {
197 return $res;
198 }
199 }
200
201 return false;
202 }
203
204 public function archiveCampaign($engine, $campaignId)
205 {
206 if($this->getAppID() && $this->getAppSecret() && $engine)
207 {
209 "engine" => $engine,
210 "campaign" => $campaignId
211 ));
212
213 if(!isset($res['error']))
214 {
215 return $res['result'];
216 }
217 else
218 {
219 return $res;
220 }
221 }
222
223 return false;
224 }
225
226 public function unArchiveCampaign($engine, $campaignId)
227 {
228 if($this->getAppID() && $this->getAppSecret() && $engine)
229 {
231 "engine" => $engine,
232 "campaign" => $campaignId
233 ));
234
235 if(!isset($res['error']))
236 {
237 return $res['result'];
238 }
239 else
240 {
241 return $res;
242 }
243 }
244
245 return false;
246 }
247
248 public function resumeCampaign($engine, $campaignId)
249 {
250 if($this->getAppID() && $this->getAppSecret() && $engine)
251 {
253 "engine" => $engine,
254 "campaign" => $campaignId
255 ));
256
257 if(!isset($res['error']))
258 {
259 return $res['result'];
260 }
261 else
262 {
263 return $res;
264 }
265 }
266
267 return false;
268 }
269
270 public function stopCampaign($engine, $campaignId)
271 {
272 if($this->getAppID() && $this->getAppSecret() && $engine)
273 {
275 "engine" => $engine,
276 "campaign" => $campaignId
277 ));
278
279 if(!isset($res['error']))
280 {
281 return $res['result'];
282 }
283 else
284 {
285 return $res;
286 }
287 }
288
289 return false;
290 }
291
292 public function deleteCampaign($engine, $campaignId)
293 {
294 if($this->getAppID() && $this->getAppSecret() && $engine)
295 {
297 "engine" => $engine,
298 "campaign" => $campaignId
299 ));
300
301 if(!isset($res['error']))
302 {
303 return $res['result'];
304 }
305 else
306 {
307 return $res;
308 }
309 }
310
311 return false;
312 }
313
314 public function addBanner($engine, array $bannerParam)
315 {
316 if($this->getAppID() && $this->getAppSecret() && $engine)
317 {
318 $res = $this->getTransport()->call(
320 array(
321 "engine" => $engine,
322 "banner" => $bannerParam
323 )
324 );
325
326 if(!isset($res['error']))
327 {
328 return $res['result'];
329 }
330 else
331 {
332 return $res;
333 }
334 }
335
336 return false;
337 }
338
339 public function updateBanner($engine, array $bannerParam)
340 {
341 if($this->getAppID() && $this->getAppSecret() && $engine)
342 {
343 $res = $this->getTransport()->call(
345 array(
346 "engine" => $engine,
347 "banner" => $bannerParam
348 )
349 );
350
351 if(!isset($res['error']))
352 {
353 return $res['result'];
354 }
355 else
356 {
357 return $res;
358 }
359 }
360
361 return false;
362 }
363
364 public function getBannerList($engine, $filter)
365 {
366 if($this->getAppID() && $this->getAppSecret() && $engine)
367 {
369 'engine' => $engine,
370 'filter' => $filter
371 ));
372
373 if(!isset($res['error']))
374 {
375 return $res['result'];
376 }
377 else
378 {
379 return $res;
380 }
381 }
382
383 return false;
384 }
385
387 {
388 if($this->getAppID() && $this->getAppSecret() && $engine)
389 {
391 'engine' => $engine,
392 'filter' => $filter
393 ));
394
395 if(!isset($res['error']))
396 {
397 return $res['result'];
398 }
399 else
400 {
401 return $res;
402 }
403 }
404
405 return false;
406 }
407
408 public function stopBanners($engine, $filter)
409 {
410 if($this->getAppID() && $this->getAppSecret() && $engine)
411 {
413 'engine' => $engine,
414 'filter' => $filter
415 ));
416
417 if(!isset($res['error']))
418 {
419 return $res['result'];
420 }
421 else
422 {
423 return $res;
424 }
425 }
426
427 return false;
428 }
429
430 public function resumeBanners($engine, $filter)
431 {
432 if($this->getAppID() && $this->getAppSecret() && $engine)
433 {
435 'engine' => $engine,
436 'filter' => $filter
437 ));
438
439 if(!isset($res['error']))
440 {
441 return $res['result'];
442 }
443 else
444 {
445 return $res;
446 }
447 }
448
449 return false;
450 }
451
453 {
454 if($this->getAppID() && $this->getAppSecret() && $engine)
455 {
457 'engine' => $engine,
458 'filter' => $filter
459 ));
460
461 if(!isset($res['error']))
462 {
463 return $res['result'];
464 }
465 else
466 {
467 return $res;
468 }
469 }
470
471 return false;
472 }
473
475 {
476 if($this->getAppID() && $this->getAppSecret() && $engine)
477 {
479 'engine' => $engine,
480 'filter' => $filter
481 ));
482
483 if(!isset($res['error']))
484 {
485 return $res['result'];
486 }
487 else
488 {
489 return $res;
490 }
491 }
492
493 return false;
494 }
495
496 public function deleteBanners($engine, $filter)
497 {
498 if($this->getAppID() && $this->getAppSecret() && $engine)
499 {
501 'engine' => $engine,
502 'filter' => $filter
503 ));
504
505 if(!isset($res['error']))
506 {
507 return $res['result'];
508 }
509 else
510 {
511 return $res;
512 }
513 }
514
515 return false;
516 }
517
518 public function getRegions($engine)
519 {
520 if($this->getAppID() && $this->getAppSecret() && $engine)
521 {
523 'engine' => $engine
524 ));
525
526 if(!isset($res['error']))
527 {
528 return $res['result'];
529 }
530 else
531 {
532 return $res;
533 }
534 }
535
536 return false;
537 }
538
545 {
546 if($this->getAppID() && $this->getAppSecret() && $engine)
547 {
549 'engine' => $engine
550 ));
551
552 if(!isset($res['error']))
553 {
554 return $res['result'];
555 }
556 else
557 {
558 return $res;
559 }
560 }
561
562 return false;
563 }
564
565
566 public function createWordstatReport($engine, $queryData)
567 {
568 if($this->getAppID() && $this->getAppSecret() && $engine)
569 {
571 'engine' => $engine,
572 'query' => $queryData,
573 ));
574
575 if(!isset($res['error']))
576 {
577 return $res['result'];
578 }
579 else
580 {
581 return $res;
582 }
583 }
584
585 return false;
586 }
587
588 public function deleteWordstatReport($engine, $reportId)
589 {
590 if($this->getAppID() && $this->getAppSecret() && $engine)
591 {
593 'engine' => $engine,
594 'reportId' => $reportId,
595 ));
596
597 if(!isset($res['error']))
598 {
599 return $res['result'];
600 }
601 else
602 {
603 return $res;
604 }
605 }
606
607 return false;
608 }
609
610 public function getWordstatReport($engine, $reportId)
611 {
612 if($this->getAppID() && $this->getAppSecret() && $engine)
613 {
615 'engine' => $engine,
616 'reportId' => $reportId,
617 ));
618
619 if(!isset($res['error']))
620 {
621 return $res['result'];
622 }
623 else
624 {
625 return $res;
626 }
627 }
628
629 return false;
630 }
631
633 {
634 if($this->getAppID() && $this->getAppSecret() && $engine)
635 {
637 'engine' => $engine,
638 ));
639
640 if(!isset($res['error']))
641 {
642 return $res['result'];
643 }
644 else
645 {
646 return $res;
647 }
648 }
649
650 return false;
651 }
652 public function createForecastReport($engine, $queryData)
653 {
654 if($this->getAppID() && $this->getAppSecret() && $engine)
655 {
657 'engine' => $engine,
658 'query' => $queryData,
659 ));
660
661 if(!isset($res['error']))
662 {
663 return $res['result'];
664 }
665 else
666 {
667 return $res;
668 }
669 }
670
671 return false;
672 }
673
674 public function deleteForecastReport($engine, $reportId)
675 {
676 if($this->getAppID() && $this->getAppSecret() && $engine)
677 {
679 'engine' => $engine,
680 'reportId' => $reportId,
681 ));
682
683 if(!isset($res['error']))
684 {
685 return $res['result'];
686 }
687 else
688 {
689 return $res;
690 }
691 }
692
693 return false;
694 }
695
696 public function getForecastReport($engine, $reportId)
697 {
698 if($this->getAppID() && $this->getAppSecret() && $engine)
699 {
701 'engine' => $engine,
702 'reportId' => $reportId,
703 ));
704
705 if(!isset($res['error']))
706 {
707 return $res['result'];
708 }
709 else
710 {
711 return $res;
712 }
713 }
714
715 return false;
716 }
717
719 {
720 if($this->getAppID() && $this->getAppSecret() && $engine)
721 {
723 'engine' => $engine,
724 ));
725
726 if(!isset($res['error']))
727 {
728 return $res['result'];
729 }
730 else
731 {
732 return $res;
733 }
734 }
735
736 return false;
737 }
738
740 {
741 if($this->getAppID() && $this->getAppSecret() && $engine)
742 {
744 'engine' => $engine,
745 'params' => $params,
746 ));
747
748 if(!isset($res['error']))
749 {
750 return $res['result'];
751 }
752 else
753 {
754 return $res;
755 }
756 }
757
758 return false;
759 }
760
761 private function getProxyUrl(): string
762 {
763 return $this->proxyUrl ?: BITRIXSEO_URL;
764 }
765
772 {
773 $this->proxyUrl = $proxyUrl;
774
775 return $this;
776 }
777}
778
780{
781 const METHOD_CLIENT_INFO = 'seo.client.info';
782 const METHOD_CLIENT_LIST = 'seo.client.list';
783 const METHOD_CLIENT_AUTH_CLEAR = 'seo.client.auth.clear';
784
785 const METHOD_CAMPAIGN_ADD = 'seo.campaign.add';
786 const METHOD_CAMPAIGN_UPDATE = 'seo.campaign.update';
787 const METHOD_CAMPAIGN_GET = 'seo.campaign.get';
788 const METHOD_CAMPAIGN_LIST = 'seo.campaign.list';
789 const METHOD_CAMPAIGN_ARCHIVE = 'seo.campaign.archive';
790 const METHOD_CAMPAIGN_UNARCHIVE = 'seo.campaign.unarchive';
791 const METHOD_CAMPAIGN_RESUME = 'seo.campaign.resume';
792 const METHOD_CAMPAIGN_STOP = 'seo.campaign.stop';
793 const METHOD_CAMPAIGN_DELETE = 'seo.campaign.delete';
794
795 const METHOD_BANNER_ADD = 'seo.banner.add';
796 const METHOD_BANNER_UPDATE = 'seo.banner.update';
797 const METHOD_BANNER_LIST = 'seo.banner.list';
798 const METHOD_BANNER_MODERATE = 'seo.banner.moderate';
799 const METHOD_BANNER_ARCHIVE = 'seo.banner.archive';
800 const METHOD_BANNER_UNARCHIVE = 'seo.banner.unarchive';
801 const METHOD_BANNER_RESUME = 'seo.banner.resume';
802 const METHOD_BANNER_STOP = 'seo.banner.stop';
803 const METHOD_BANNER_DELETE = 'seo.banner.delete';
804
805 const METHOD_REGION_GET = 'seo.region.get';
806 const METHOD_CLIENTS_GET = 'seo.clients.get';
807
808 const METHOD_REPORT_WORDSTAT_CREATE = 'seo.report.wordstat.create';
809 const METHOD_REPORT_WORDSTAT_DELETE = 'seo.report.wordstat.delete';
810 const METHOD_REPORT_WORDSTAT_GET = 'seo.report.wordstat.get';
811 const METHOD_REPORT_WORDSTAT_LIST = 'seo.report.wordstat.list';
812
813 const METHOD_REPORT_FORECAST_CREATE = 'seo.report.forecast.create';
814 const METHOD_REPORT_FORECAST_DELETE = 'seo.report.forecast.delete';
815 const METHOD_REPORT_FORECAST_GET = 'seo.report.forecast.get';
816 const METHOD_REPORT_FORECAST_LIST = 'seo.report.forecast.list';
817
818 const METHOD_STAT_GET = 'seo.stat.get';
819
820 public function __construct($clientId, $clientSecret, $serviceUrl = '')
821 {
822 $serviceUrl = $serviceUrl ?: CBitrixSeoOAuthInterface::URL;
823 $this->setSeviceHost($serviceUrl);
824 return parent::__construct($clientId, $clientSecret);
825 }
826
827 public function getClientInfo()
828 {
829 return $this->call(self::METHOD_CLIENT_INFO);
830 }
831
832 public function getClientList()
833 {
834 return $this->call(self::METHOD_CLIENT_LIST);
835 }
836
837 public function clearClientAuth($engine, $clientId = null)
838 {
839 return $this->call(self::METHOD_CLIENT_AUTH_CLEAR, array("engine" => $engine, "proxy_client_id" => $clientId));
840 }
841}
resumeCampaign($engine, $campaignId)
Определения bitrixseo.php:248
moderateBanners($engine, $filter)
Определения bitrixseo.php:386
__construct($appID=false, $appSecret=false, $code=false)
Определения bitrixseo.php:35
updateCampaign($engine, array $campaignParams)
Определения bitrixseo.php:133
getClientInfo()
Определения bitrixseo.php:63
getForecastReport($engine, $reportId)
Определения bitrixseo.php:696
const URL
Определения bitrixseo.php:24
getBannerStats($engine, array $params)
Определения bitrixseo.php:739
stopBanners($engine, $filter)
Определения bitrixseo.php:408
getWordstatReport($engine, $reportId)
Определения bitrixseo.php:610
getCampaignList($engine)
Определения bitrixseo.php:183
updateBanner($engine, array $bannerParam)
Определения bitrixseo.php:339
getTransport()
Определения bitrixseo.php:53
deleteForecastReport($engine, $reportId)
Определения bitrixseo.php:674
getCampaign($engine, array $campaignParams)
Определения bitrixseo.php:158
clearClientAuth($engine, $clientId=null)
Определения bitrixseo.php:93
unArchiveBanners($engine, $filter)
Определения bitrixseo.php:474
getWordstatReportList($engine)
Определения bitrixseo.php:632
resumeBanners($engine, $filter)
Определения bitrixseo.php:430
unArchiveCampaign($engine, $campaignId)
Определения bitrixseo.php:226
getRegions($engine)
Определения bitrixseo.php:518
createForecastReport($engine, $queryData)
Определения bitrixseo.php:652
addCampaign($engine, array $campaignParams)
Определения bitrixseo.php:108
const SERVICE_ID
Определения bitrixseo.php:22
getBannerList($engine, $filter)
Определения bitrixseo.php:364
archiveBanners($engine, $filter)
Определения bitrixseo.php:452
deleteBanners($engine, $filter)
Определения bitrixseo.php:496
stopCampaign($engine, $campaignId)
Определения bitrixseo.php:270
string $proxyUrl
Определения bitrixseo.php:26
addBanner($engine, array $bannerParam)
Определения bitrixseo.php:314
getClientList()
Определения bitrixseo.php:78
archiveCampaign($engine, $campaignId)
Определения bitrixseo.php:204
deleteWordstatReport($engine, $reportId)
Определения bitrixseo.php:588
createWordstatReport($engine, $queryData)
Определения bitrixseo.php:566
getClientsSettings($engine)
Определения bitrixseo.php:544
deleteCampaign($engine, $campaignId)
Определения bitrixseo.php:292
getForecastReportList($engine)
Определения bitrixseo.php:718
setProxyUrl(string $proxyUrl)
Определения bitrixseo.php:771
const METHOD_REPORT_FORECAST_LIST
Определения bitrixseo.php:816
getClientInfo()
Определения bitrixseo.php:827
const METHOD_REPORT_WORDSTAT_LIST
Определения bitrixseo.php:811
const METHOD_CAMPAIGN_ARCHIVE
Определения bitrixseo.php:789
const METHOD_CLIENT_AUTH_CLEAR
Определения bitrixseo.php:783
const METHOD_CLIENT_LIST
Определения bitrixseo.php:782
const METHOD_CLIENT_INFO
Определения bitrixseo.php:781
const METHOD_BANNER_MODERATE
Определения bitrixseo.php:798
const METHOD_BANNER_UPDATE
Определения bitrixseo.php:796
const METHOD_CAMPAIGN_DELETE
Определения bitrixseo.php:793
const METHOD_REPORT_WORDSTAT_GET
Определения bitrixseo.php:810
const METHOD_REPORT_FORECAST_CREATE
Определения bitrixseo.php:813
const METHOD_BANNER_LIST
Определения bitrixseo.php:797
const METHOD_CAMPAIGN_STOP
Определения bitrixseo.php:792
const METHOD_BANNER_UNARCHIVE
Определения bitrixseo.php:800
const METHOD_CAMPAIGN_LIST
Определения bitrixseo.php:788
clearClientAuth($engine, $clientId=null)
Определения bitrixseo.php:837
const METHOD_BANNER_ADD
Определения bitrixseo.php:795
const METHOD_CAMPAIGN_ADD
Определения bitrixseo.php:785
const METHOD_BANNER_DELETE
Определения bitrixseo.php:803
const METHOD_STAT_GET
Определения bitrixseo.php:818
const METHOD_CAMPAIGN_RESUME
Определения bitrixseo.php:791
const METHOD_BANNER_ARCHIVE
Определения bitrixseo.php:799
const METHOD_BANNER_STOP
Определения bitrixseo.php:802
const METHOD_CAMPAIGN_GET
Определения bitrixseo.php:787
const METHOD_REPORT_FORECAST_GET
Определения bitrixseo.php:815
const METHOD_CAMPAIGN_UNARCHIVE
Определения bitrixseo.php:790
const METHOD_CAMPAIGN_UPDATE
Определения bitrixseo.php:786
getClientList()
Определения bitrixseo.php:832
const METHOD_REGION_GET
Определения bitrixseo.php:805
__construct($clientId, $clientSecret, $serviceUrl='')
Определения bitrixseo.php:820
const METHOD_CLIENTS_GET
Определения bitrixseo.php:806
const METHOD_REPORT_FORECAST_DELETE
Определения bitrixseo.php:814
const METHOD_REPORT_WORDSTAT_DELETE
Определения bitrixseo.php:809
const METHOD_REPORT_WORDSTAT_CREATE
Определения bitrixseo.php:808
const METHOD_BANNER_RESUME
Определения bitrixseo.php:801
setSeviceHost($host)
Определения bitrixservice.php:57
call($methodName, $additionalParams=null, $licenseCheck=false)
Определения bitrixservice.php:67
static GetOption($opt)
Определения authmanager.php:1339
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$filter
Определения iblock_catalog_list.php:54
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$engine
Определения options.php:121
$clientId
Определения seo_client.php:18