Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
cloud.php
1<?php
2
4
6
7class Cloud
8{
9 static protected $url = 'https://analytics.bitrix.info/crecoms/v1_0/recoms.php';
10
11 public static function getPersonalRecommendation($userId, $count = 10)
12 {
13 $params = array(
14 'aid' => Counter::getAccountId(),
15 'op' => 'recommend',
16 'local_uid' => $userId,
17 'count' => $count+10
18 );
19
20 $result = static::makeQuery($params);
21
22 return $result;
23 }
24
25 public static function getFollowUpProducts($productIds)
26 {
27 $params = array(
28 'aid' => Counter::getAccountId(),
29 'op' => 'postcross',
30 'eids' => join(',', $productIds),
31 'count' => 20
32 );
33
34 $result = static::makeQuery($params);
35
36 return $result;
37 }
38
39 public static function getPotentialConsumers($productId)
40 {
41 $params = array(
42 'aid' => Counter::getAccountId(),
43 'op' => 'consumers',
44 'eid' => $productId
45 );
46
47 $result = static::makeQuery($params);
48
49 return $result;
50 }
51
52 protected static function makeQuery($params)
53 {
54 // aid is always required
55 $params['aid'] = \Bitrix\Main\Analytics\Counter::getAccountId();
56
57 // send http query
58 $http = new \Bitrix\Main\Web\HttpClient();
59 $http->setHeader("User-Agent", "X-Bitrix-Sale");
60
61 $httpResult = $http->get(static::$url.'?'.http_build_query($params));
62
63 if ($http->getStatus() == 200)
64 {
65 return json_decode($httpResult, true);
66 }
67 }
68}
static getPersonalRecommendation($userId, $count=10)
Definition cloud.php:11
static getPotentialConsumers($productId)
Definition cloud.php:39
static getFollowUpProducts($productIds)
Definition cloud.php:25
static makeQuery($params)
Definition cloud.php:52