-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bundit J
authored and
Bundit J
committed
Oct 8, 2016
1 parent
b1cd354
commit e708138
Showing
6 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# linebot | ||
|
||
LINE Messaging API for Node.js | ||
|
||
[![NPM Version][npm-image]][npm-url] | ||
[![NPM Downloads][downloads-image]][downloads-url] | ||
|
||
## About LINE Messaging API | ||
|
||
Please refer to the official API documents for details. | ||
|
||
https://devdocs.line.me | ||
|
||
## Installation | ||
|
||
``` | ||
$ npm install linebot --save | ||
``` | ||
|
||
## License | ||
|
||
[MIT](LICENSE) | ||
|
||
[npm-image]: https://img.shields.io/npm/v/linebot.svg | ||
[npm-url]: https://npmjs.org/package/linebot | ||
[downloads-image]: https://img.shields.io/npm/dm/linebot.svg | ||
[downloads-url]: https://npmjs.org/package/linebot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/*jslint node: true, es5: true*/ | ||
|
||
'use strict'; | ||
|
||
var express = require('express'); | ||
var bodyParser = require('body-parser'); | ||
var fetch = require('node-fetch'); | ||
|
||
var app = express(); | ||
app.use(bodyParser.json()); | ||
|
||
app.get('/', function (req, res) { | ||
res.send('Hello World!'); | ||
}); | ||
|
||
app.post('/linewebhook', function (req, res) { | ||
console.log(req.body); | ||
var headers = { | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json', | ||
'Authorization': 'Bearer ' + process.env.ACCESS_TOKEN | ||
}, | ||
body = { | ||
replyToken: req.body.events[0].replyToken, | ||
messages: [ | ||
{ | ||
type: "text", | ||
text: "Hello, user" | ||
} | ||
] | ||
}; | ||
console.log(headers); | ||
console.log(body); | ||
fetch('https://api.line.me/v2/bot/message/reply', { method: 'POST', headers: headers, body: JSON.stringify(body) }) | ||
.then(function (res) { | ||
console.log('Success'); | ||
console.log(res); | ||
return res.json({}); | ||
}) | ||
.catch(function (err) { | ||
console.log('Error'); | ||
console.log(err); | ||
return res.json({}); | ||
}); | ||
}); | ||
|
||
app.listen(process.env.PORT || 80, function () { | ||
console.log('Running'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
loggingEnabled: true | ||
devErrorsEnabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/*jslint node: true*/ | ||
'use strict'; | ||
|
||
module.exports = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/*jslint node: true*/ | ||
'use strict'; | ||
|
||
module.exports = {}; |