-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecofb.php
More file actions
53 lines (44 loc) · 1.47 KB
/
recofb.php
File metadata and controls
53 lines (44 loc) · 1.47 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
<?php
session_start();
$userid = $_SESSION['afeluserid'];
$rid = $_POST['rid'];
$r = $_POST['r'];
$data = array("date" => time(),
"feedbackType" => "recommClick",
"userId" => $userid,
"itemId" => $r,
"recommId" => $rid
);
$data_string = json_encode($data);
$ch = curl_init('http://afel-rec.know-center.tugraz.at/afel/data/feedback');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "reco1::eN9@L+Bl4l~29#?5");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
$dres = json_decode($result);
print_r(json_encode($dres));
/* $toreturn = array();
foreach ($dres->recomms as $rec){
$url = 'http://localhost:9200/didactalia-activity-base/resource/'.$rec;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($curl);
curl_close($curl);
$item = json_decode($res);
$rurl = "";
if (isset($item->{_source}->resource_url)){
$rurl = $item->{_source}->resource_url;
}
else if (isset($item->{_source}->link)){
$rurl = $item->{_source}->link;
}
$ditem = array("title" => $item->{_source}->title, "url"=> $rurl);
$toreturn[] = $ditem;
}
echo json_encode($toreturn); */