sudo apt-get -y install npm
npm: node package manager, Node向けパッケージ管理ツール
http://gihyo.jp/dev/serial/01/nodejs/0002
$ npm install twitter
bot.js作成
http://tips.hecomi.com/entry/20120721/1342876520
(Debian/UbuntuでNode.jsをインストールする(nvm))[http://qiita.com/tamurashingo@github/items/6348863668e1e3fd70c9]
参考:(Node.js、Socket.IO、MongoDBでリアルタイムWeb (1/2))[http://www.atmarkit.co.jp/ait/articles/1210/10/news115.html]
20 行で作る node.js による Twitter bot 作成講座
※少し古い
Twitter API client library for node.js
※新しい
Get
var util = require('util'),
twitter = require('twitter');
var bot = new twitter({
consumer_key : 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
consumer_secret : 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
access_token_key : 'xxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
access_token_secret : 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
});
bot.get('statuses/user_timeline', {screen_name: 'taikishimba'}, function(error, tweets, response) {
console.log(util.inspect(tweets));
});
$ node get
Hello Worldとポストする
var util = require('util'),
twitter = require('twitter');
var bot = new twitter({
consumer_key : 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
consumer_secret : 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
access_token_key : 'xxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
access_token_secret : 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
});
bot.post('statuses/update', {status: 'Hello Worlds'}, function(error, tweet, response) {
console.log(util.inspect(tweet));
console.log(util.inspect(response));
});
$ node post
Install MongoDB
MongoDBの薄い本内,はじめよう
$ wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-3.0.1.tgz
$ tar xzvf mongodb-linux-x86_64-ubuntu1404-3.0.1.tgz
名前が長いので,,
$ mv mongodb-linux-x86_64-ubuntu1404-3.0.1 mongodb
$ cd mongodb/bin
$ touch mongodb.config
$ vim mongodb.config
dbpath=/var/lib/mongodb/data
$ sudo mkdir /var/lib/mongodb
$ sudo mkdir /var/lib/mongodb/data
$ export PATH=$PATH:/home/vagrant/mongodb/bin
$ mongod --config mongodb.config &
エラーが出たら
$ export LC_ALL=C
$ sudo mongod --config ./mongodb.config
とりあえずctrl+Cで終了
$ cd ~
$ mkdir tw2db
$ cd tw2db
$ npm install mongoose
以下参考サイト通りで実行可能
http://tips.hecomi.com/entry/20120908/1347094725
References
MongoDBの薄い本
http://www.cuspy.org/diary/2012-04-17/the-little-mongodb-book-ja.pdf
Redisの薄い本
http://openmymind.net/redis.pdf