Skip to content
咕咕机的koa2后台
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
images
public/stylesheets
routes
views
.gitignore
README.md
app.js
config.js
memobird.js
package-lock.json
package.json
url.js

README.md

咕咕机后台

才买的咕咕机,研究了一下简单的玩法

运行方法

需node.js环境

git clone或下载zip包,在文件夹内安装依赖

 npm install

然后在config.js中填入相关信息(前提是已经向咕咕机官方发邮件获取了appkey)
PS: ak,设备id,还一个userID(这个不清楚什么意思,我直接填的咕咕ID)

//运行后台
 npm start / npm run dev

项目是koa2默认生成的,默认监听3000端口 浏览器输入 http://localhost:3000/ 有画面,那后台就启动成功了

调用地址

本机调用的话ip就是127.0.0.1/localhost,如果调用了没反应检查下后台的console.log

推荐的使用方法

很多人推荐IFTTT,我看了下总觉得有点麻烦,我强力推荐node-red平台用来做监测,详见上方的博客链接

  • eg:定时获取一言的flow(在node-red右上方import这段代码即可)
[{"id":"c05f930b.68a33","type":"http request","z":"6284656.d09a29c","name":"hitokoto","method":"GET","ret":"obj","url":"https://sslapi.hitokoto.cn/","tls":"","x":431,"y":162,"wires":[["4383a923.5a6698"]]},{"id":"f831778a.769438","type":"inject","z":"6284656.d09a29c","name":"间隔打印","topic":"","payload":"","payloadType":"date","repeat":"14400","crontab":"","once":false,"x":183,"y":150,"wires":[["c05f930b.68a33"]]},{"id":"4383a923.5a6698","type":"function","z":"6284656.d09a29c","name":"处理输入","func":"\nlet text =\n`\n--------------------------------\n               一言\n        \n  ${msg.payload.hitokoto}\n\n                ---${msg.payload.from}\n--------------------------------\n`\nmsg.payload = {content: text}\nreturn msg;","outputs":1,"noerr":0,"x":639,"y":163,"wires":[["c0a30def.29e2c","7aac15b5.09a94c"]]},{"id":"7aac15b5.09a94c","type":"debug","z":"6284656.d09a29c","name":"","active":true,"console":"false","complete":"payload","x":1073,"y":165,"wires":[]},{"id":"c0a30def.29e2c","type":"http request","z":"6284656.d09a29c","name":"修改此处的URL地址","method":"POST","ret":"obj","url":"http://IP:3000/printText","tls":"","x":885,"y":207,"wires":[["7aac15b5.09a94c"]]},{"id":"8e247114.aae1e","type":"comment","z":"6284656.d09a29c","name":"一言","info":"","x":116,"y":90,"wires":[]}]
  • node-red还自带ui界面(见上方博客),所以很简单就能撸出一个前端界面控制远程打印

另外推荐一个大佬的微博订阅RSS,同理,直接用node-red订阅这个RSS然后,调用这个后台接口,还不美滋滋(但我还缺了点那啥,也没什么好订阅的(T_T))

推荐一个在线的node-red平台,但存在inject输入指定时间无法触发的bug,后来我还是把node-red架到自己的windows服务器上了

API的单独的使方法(见router文件夹内index.js的路由)

const memobird = new Memobird({ak: config.ak,memobirdID: config.memobirdID,useridentifying: config.useridentifying})
memobird.init()
.then(() => memobird.printText(ctx.request.body.content))
.then( res => memobird.status(res.printcontentid, 3000))
.then(printflag => {
console.log('检测完成',printflag === 1 ? '打印完成' : '打印未完成')
})
.catch((err) => {
console.log(err)
})
You can’t perform that action at this time.