呟くまでのメモで参考にさせていただいた記事
環境構築、ボタン押下テストまで
twitterにつぶやくところ
http://tips.hecomi.com/entry/20120721/1342876520
http://qiita.com/daikingca2/items/0d2840761299bcc66eff
(keyとtokenは既存の物を利用。初取得の場合は、 https://syncer.jp/twitter-api-matome ここらあたりを見れば分かるんじゃないか)
上記記事を実際になぞってみてつまづいた所
npm install node-dash-button --save 実行時に、下記のエラーが出力される。
npm ERR! Darwin 15.6.0
npm ERR! argv "/Users/xxx/.nodebrew/node/v7.2.1/bin/node" "/Users/xxx/.nodebrew/current/bin/npm" "install" "node-dash-button" "--save"
npm ERR! node v7.2.1
npm ERR! npm v3.10.10
npm ERR! code ENOSELF
npm ERR! Refusing to install node-dash-button as a dependency of itself
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! https://github.com/npm/npm/issues
npm ERR! Please include the following file with any support request:
npm ERR! /Users/xxx/node-dash-button/npm-debug.log
原因、対処策
package.json 内の "name" が、ディレクトリ名と同じだとNG
下記を参考にさせていただき、"name" を変更し、再度
npm install node-dash-button --save 実行
http://mksk.hatenadiary.com/entry/2016/10/03/092932
sudo node sample.js しても押下の検出がされない
コンソールに何も表示されない
原因、対処策
色々な記事にも書かれているが、Amazon Dash Button の動作が遅い。
そのため根気よく待つと表示された。
node-twitterをインストールし、つぶやこうとするも
bot.updateStatus('Hello, world!', function (data) {
のupdateStatusにて
TypeError: bot.updateStatus is not a function
が表示されエラーとなる。
原因、対処策
updateStatus ではなく、
bot.post('statuses/update',
{status: 'Hello world (このツイートはテストです)'},
function(error, tweet, response) {
if (!error) {
console.log(tweet)
}
});
を使うようにした。
エラーが表示されないが、つぶやけていない
原因、対処策
古いKeyとtokenを使用していた。
下記を参考にしにて再登録
http://qiita.com/rarewin/items/d38ba161864107f94f7d
一度しかつぶやけない
原因
同じ文面だと多重投稿禁止?かなにかでつぶやけない。
http://qiita.com/n0bisuke/items/dd28122d006c95c58f9c
上記にて日付をいれた。