我正在使用twitter streaming api
&johnny-five
与其他一些模块http
,express
&socket.io
与arduino uno
我的脚本在笔记本电脑上运行良好。但我的作品将在平板电脑上进行。我有两台平板电脑,两者的反应不同。在hp omni
平板电脑上我收到以下错误
我也arduino-uno
连接了端口COM3
,但它的显示设备已连接COM1
据我所知,这个错误是standard firmata
在arduino中没有上传时引起的。我已经上传了这个程序,它在笔记本电脑上运行良好
在Acer
平板电脑上,我没有收到任何错误,程序启动得很好,没有任何问题,但我没有收到推文twitter streaming api
我已经检查了很多次,每次我运行它时它都在笔记本电脑上运行得很好,但是给出了两个不同的问题tablets
这是我正在使用的代码
var Twitter = require('twitter');
var five = require("johnny-five");
var express = require('express')
, app = express()
, http = require('http')
, server = http.createServer(app)
, io = require('socket.io').listen(server);
server.listen(8080);
// routing
app.use(express.static(__dirname + '/http'));
app.use(function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', "http://"+req.headers.host+':80');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
next();
}
);
var client = new Twitter({
consumer_key: 'abc',
consumer_secret: 'abc',
access_token_key: 'abc',
access_token_secret: 'abc'
});
var board = new five.Board();
board.on("ready", function() {
this.pinMode(5, five.Pin.OUTPUT);
this.pinMode(10, five.Pin.INPUT);
//Ask to visit url
console.log("Visit http://localhost:8080");
var randomHashtag = Math.floor((Math.random() * 10000) +1);
var count = 0;//Initialize counter
io.sockets.on('connection', function (socket) {
console.log('Ready to recieve tweets');//Prints Message when Socket.io is ready to recieve tweets
io.emit('stream',{number:randomHashtag});//Send random no when socket initzilize
client.stream('statuses/filter', {track: '#tweetMe'}, function(stream) {
stream.on('data', function(tweet) {
if(tweet.text.search(randomHashtag) > 0){
count++;//Increment pending tweets
randomHashtag = Math.floor((Math.random() * 10000) +1);
io.emit('stream',{number:randomHashtag});
board.digitalWrite(5,1);
console.log(tweet.text);
}
else{
console.log("Tweet Without random No");
}
});
stream.on('error', function(error) {
throw error;
});
});
});
});