Created
January 9, 2017 21:30
-
-
Save icalik/9b569f32e3b6f44295a6072c4b84f83a to your computer and use it in GitHub Desktop.
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
var Twit = require('twit'); //This is import statement. | |
var config = require('./config'); | |
var T = new Twit(config); | |
var stream = T.stream('user'); | |
stream.on('follow',followed); | |
function followed(eventMsg) { | |
var name = eventMsg.source.name; | |
var screenName = eventMsg.source.screen_name; | |
var user_id = eventMsg.source.id; | |
tweetIt('@' + screenName + ' Takip ettiğin için teşekkürler, mobil bildirimleri açmayı unutma!'); | |
follow_user(user_id); | |
} | |
function follow_user(user_id) { | |
T.post('friendships/create',{ user_id }); | |
} | |
function tweetIt(txt) { | |
var tweet = { | |
status : txt | |
} | |
//// | |
T.post('statuses/update',tweet,tweeted); | |
function tweeted(err,data,response) { | |
if (err) { | |
console.log("Something went wrong on tweet!"); | |
} | |
else{ | |
console.log("It Works!"); | |
} | |
} | |
//// | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment