实践easyRec2
来源:互联网 发布:域名模糊查询 编辑:程序博客网 时间:2024/06/15 09:52
下载安装好easyRec之后开始操作使用。
1.新建Tenant,按照操作执行即可。website我使用的是我本地的一个项目做测试。
2.import item,我在js里面调用官方API,第一个问题涉及到跨域问题,使用jsonp解决。
添加item 代码如下:
function addItem() { var add_url = "http://localhost:8081/easyrec-web/api/1.1/importitem?callback=?"; var parmas = { 'token': 'f68f945939c5a6dd4cbe2d322f2943bf', 'tenantid': 'weidao', 'itemid': '34011', 'itemdescription': '德国Almkind鲜榨(NFC)梨汁500ml', 'itemurl': 'http://localhost:8080/product/content/201704/34012.html', 'dtype':'jsonp', '_': new Date().getTime() }; $.getJSON(add_url, parmas, function (transport) { var json = eval(transport); console.log(json); }); }
3.添加view信息,跟添加item类似。
function addView() { var view_url="http://localhost:8081/easyrec-web/api/1.1/view?callback=?"; var params={ 'apikey':'6491d97a8a0c3f7d07b1df5d83a83521', 'tenantid':'weidao', 'sessionid':'testtesttesttest', 'itemid':'34011', 'itemdescription':'德国Almkind鲜榨(NFC)梨汁500ml', 'itemimageurl':'http://image.weidao.com/upload/image//upload/image/201704/3c378120-9900-4a01-bd44-c0b1fe815f90-medium.jpg', 'itemurl':'http://localhost:8080/product/content/201704/34012.html', 'userid':'67623', 'dtype':'jsonp', '_': new Date().getTime() }; $.getJSON(view_url,params,function (json) { console.log(json); }); }
4.简单测试访问最多的item
function mostviewtest() { var user_view_url='http://localhost:8081/easyrec-web/api/1.1/json/mostvieweditems?callback=?'; var params = { 'apikey':'6491d97a8a0c3f7d07b1df5d83a83521', 'tenantid':'testweidao', 'itemid':'34011', 'dtype':'jsonp', '_': new Date().getTime() }; $.getJSON(user_view_url,params,function(transport) { var json = eval(transport); console.log(json); }); }
最后结果正常返回
{action: "mostvieweditems",userid: null,sessionid: null,recommendedItems: [{itemType: "ITEM",value: 3,creationDate: "2017-08-03 16:13:52.0",id: "34011",description: "500ml",url: "http://localhost:8080/product/content/201704/34012.html",imageUrl: "http://image.weidao.com/upload/image//upload/image/201704/3c378120-9900-4a01-bd44-c0b1fe815f90-medium.jpg",profileData: null}],tenantid: "weidao",baseitem: null}
阅读全文
1 0
- 实践easyRec2
- 实践
- 实践
- 实践
- 实践
- 实践
- 实践
- 实践
- 实践
- 实践
- 实践、实践、再实践
- Ant实践
- Ant实践
- Ant实践
- Ant实践
- POI 实践
- 安全管理实践
- Ant实践
- New Start
- Java enum的用法详解
- 制作一个节点的镜像
- 关于正弦振动与随机振动的后处理——特征点
- 选择工控,你后悔吗?
- 实践easyRec2
- PIC18F,ADC多通道采集,定时采集
- echarts-基本实例、常见参数配置
- dao层和service层的同时存在的意义
- Vue 2.x 如何利用proxyTable实现跨域请求(反向代理)
- c#书写中遇到的一些错误和注意点
- 关于牛客刷题笔记
- Oil Deposits
- Java学习 --- 继承