刚上班有点萌新 所以求助大家QAQ
需求是这样的: 需要从digital ocean上部署的一个nodejs server上, 向Zoho CRM的api query数据(比如user list 之类 自定义即可, 我自己开了个账号 给了sample data).
我现在nodejs 已经在digital ocean上部署好了,而且还在godaddy买了个域名对应DNS也连上了(虽然我也不知道干什么用)
然后写了一段建立server, 监听端口3000, 并收集资料转化为json的代码.
我不是很懂怎么通过这个oauth2, 我能生成一个oauth token 通过zoho crm, 之后是不是要把这个token代码放到下面的这个nodejs代码里?
然后我也不知道怎么specify路径到我的账号(也就是获取我的账号里的user数据)
我对这个过程的理解是通过CRM提供的api, 以rest的方式 获取他的数据 然后展现在nodejs的server上.
希望大家帮忙看看我的问题, 我也想学习rest api的用法. 谢谢啦!!
```
const http = require('http');
const hostname = 'localhost';
const port = 3000;
http.get({
protocol: "http:",
hostname: "localhost",
port: 3000,
path: "/api.rsc/Accounts?$filter=" + encodeURIComponent("Industry eq 'Data/Telecom OEM'"),
auth: 'MyUser:MyAuthtoken'
},
function(res) {
var body = '';
res.on('data', function(chunk) {
body += chunk;
});
res.on('end', function() {
console.log(body);
var jsonData = JSON.parse(body);
});
}).on('error', function(e) {
console.log("Error: ", e);
});
const server = http.createServer((req,res)=>{
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World!\n');
});
server.listen(port, hostname, ()=> {
console.log('Server running at http://${hostname}:${port}/');
})
//https://crm.zoho.com/crm/private/json/CustomModule1/searchRecords?newFormat=2&authtoken=YOURAPITOKEN&scope=crmapi&criteria=(YOURCRITERIA)
```
|