twitst4tz

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 29ebb71e77789d6f61a9877278dbb3fc6aadfaf5
parent be1624265341db49e429f1ba7deb9482a72e2358
Author: underd0g1 <hide4@comcast.net>
Date:   Wed, 29 Apr 2020 23:17:26 -0400

додане співвідношення користувачів

Diffstat:
Mindex.js | 44+++++++++++++++++++++++++++++++++++++-------
Mpublic/css/stylesheet.css | 2+-
Mviews/postpage.ejs | 10+++++-----
Mviews/senditpage.ejs | 2+-
4 files changed, 44 insertions(+), 14 deletions(-)

diff --git a/index.js b/index.js @@ -48,7 +48,9 @@ app.post('/sendit', function(req, res){ console.log('Connected'); //use the twit API to get a constant flow of data from twitter about a certain keyword.(s) - var stream = T.stream('statuses/filter', { track: '#coding', language: 'en' }); + var stream = T.stream('statuses/filter', { track: tag , language: 'en' }, function(){ + console.log(tag); + }); //twit fucntion with callback to log the tweets and send them to socket.io stream.on('tweet', function (tweet) { console.log(tweet.text); @@ -56,13 +58,41 @@ app.post('/sendit', function(req, res){ socket.emit('stream',tweet.text); //render the sendit page - - }); - - - }); -res.render("senditpage"); +res.render("postpage"); }); + +app.post('/followerstatspage', function(req, res){ + + console.log('triggered the userstats page'); + var username = req.body.username; + var bearer = 'AAAAAAAAAAAAAAAAAAAAAGLfBQEAAAAAVeDxlZsqNtyYsN4qMmfrrKBDbUM%3DisXeBus50iY7LzBBJBiNXJpyllGkEaVnRNMdLJTvtdHX7MLxQ0'; + async function userdata (username){ + var url = 'https://api.twitter.com/1.1/users/show.json?screen_name=The_BDav'; + var request =await fetch(url, { + method: 'GET', + headers: { + Authorization: 'Bearer '+ bearer + } + }); + var response = await request.json() + //test to make sure the data is coming in correctly + // console.log (response); + + console.log(response.screen_name); + console.log(response.followers_count); + console.log(response.friends_count) + var ratio = (response.friends_count / response.followers_count); + console.log(ratio); + + //grab the actual data that we want to display to the end user + //which would be : + // neatly displayed list of followers + // thier ratio of followers to friends + // follwers who follow them (friends) + // maybe longest friends , friends with most followers + + } +}) diff --git a/public/css/stylesheet.css b/public/css/stylesheet.css @@ -11,7 +11,7 @@ p {font-size: 16px;} color: #ffffff; } .bg-2 { - background-color: #474e5d; /* Dark Blue */ + background-color: #6f567b; /* Dark Blue */ color: #ffffff; } .bg-3 { diff --git a/views/postpage.ejs b/views/postpage.ejs @@ -8,9 +8,9 @@ <link rel = 'stylesheet' href = '/css/stylesheet.css'> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet"> - <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> + <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> - <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.min.js"></script> + <script src="/socket.io/socket.io.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"></script> @@ -53,15 +53,15 @@ <h3 class="margin">./Run</h3> <p><h4>Check out some live tweets for a certain word or hashtag</h4> </p> - <div align = 'center'> + <script> var socket = io.connect('http://localhost:3000'); socket.on('stream', function(tweet){ $('#tweetd').append(tweet+'<br>'); }); </script> - <div id="tweetd"></div> - </div> + <div id="tweetd" style = "height:320px; width:auto; overflow: auto;"></div> + </div> </div> diff --git a/views/senditpage.ejs b/views/senditpage.ejs @@ -1,6 +1,7 @@ <script src="/socket.io/socket.io.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"></script> +<h1> hello world</h1> <script> var socket = io.connect('http://localhost:3000'); @@ -9,4 +10,3 @@ }); </script> <div id="tweetd"></div> -</div>