15.4: Twitter API Basics - Twitter Bot Tutorial
ฝัง
- เผยแพร่เมื่อ 22 ส.ค. 2024
- This video covers the basics of the twitter API. What are the basic commands -- get, post, stream? How do you search twitter? How do you post a tweet? How do you trigger a function callback when a twitter event occurs?
All examples: github.com/shi...
Twit package: github.com/tte...
Twitter API documentation: dev.
Contact: / shiffman
Next video:
• 15.5: Scheduling Tweet...
Learn JavaScript basics:
• Start learning here!
Learn Processing basics:
www.youtube.co...
More about data and APIs:
• 10: Working with data ...
Help us caption & translate this video!
amara.org/v/Qbtp/
📄 Code of Conduct: github.com/Cod...
I really like your teaching style, enthusiasm and sense of humour! Thank you, really teaching me a lot!
If you could do an update for this one, that would be great! Twitter API V2 doesn't have the same endpoint access as V1 so I had to build out my search request using fetch. The video was super helpful in helping me better understand how to use Twitter's API and Node!
how did you end up doing this?
Twitter API is ded
At least we can show we tried. Ø
@@IMMERSIVEVOICEwhy u say that
I don't use Twitter but my girlfriend loves it. It was a really really awesome feeling being able to send her a tweet from code. Im not sure how to describe but it felt really freaking cool. Thanks a lot for the knowledge Mr. Shiffman
So great to hear, thank you!
If I had a teacher like you, I would have never hated programming in my school ✌️
If I had a teacher like Shiffman I would have been taught programming in school :(
@@lukem118 i really love programming but my teachers are shit she dont know anything whenever I ask something she runs away
I really like the way you teach, full of passion. Thank you
This really helped me understand how to use information in a JSON file
This helped me understand callback functions
I like your your way of teaching. I appreciate your effort. thank very much sensei
Ice poseidon does not always make coding videos, but when he does it's fu**ing awesome
This dude is getting high from just coding. XD. I love the energy.
This may be the series that I was looking for! Thank you and keep it up.
+Josh Hwang so glad to hear, thank you!
You are an amazing teacher bro :) I wish I had people like you during my University days. Keep it up!
You're an awesome teacher!! Keep it up man.
The transitions between videos is hilarious
You are my favorite professor, thanks for sharing your knowledge in the attractive way you do! Thanks a lot
Super duper helpful, Daniel! Used this to help me deploy a DM chatbot to Twitter! If I get a chance to make a video of myself building it, I'll be sure and link users to this tutorial as well. Thanks again!
the awkwardness makes the learning experience real fun
I really like the way you are teaching Thank you so much.....
If anyone is having difficulty with authentication at 7:46 just go to your Twitter Developer account and go to the App and edit it. Once you click edit then go to the permissions tab and change the permissions to read, write and direct messages. Then regenerate the key tokens and paste them into the config.js. Then you'll be fine :)
I tried as you said, but I was able to succeed, thanks anyway ø
IT WORKED!!!!!!!!!!!! YOUR VIDEOS ARE AMAZING! Love your attitude and positivity - thanks dude!
this is like a free college class, almost makes me want to go back to college
Ohh my god. You solved my task completely.
Daniel, this is really cool. Thanks for posting incredible videos!
+alexbernstine1 you're welcome! Let me know if you make something!
You're videos are a great refresher, thanks so much!
+MoistPocketsMusic thank you!
your videos are more interesting than hollywood movies...
Just started learning node.js and your video rocks! Totally helped me in doing a get request for tweets. Keep on posting the videos. I'm learning a ton from them.
One thing though, what do you use the response for? I console logged it and it was freaking huge. Not sure why that would be used or what we could get out of it.
I from Brasil! Thanks for you video! This help me so mutch!
Great tutorial, I really appreciated this video!
Very well explained.
Codin' Grain Bow is the best!
The Coding Train. I love your videos. I have learned so much. Thank you!!!!
It worked perfectly. Thank you so much!
It's actually 12.10 am where I'm watching this video at now haha
...I agree with the recent changes in the API. I mean, it's like tapping onto water or something, you have to pay, it shouldn't not had been free to begin with, data is precious, not free.
Great tutorial, many thanks!
These videos were so helpful you have no idea, thank you so much!!
awesome! i love how you explain everything, now it all seems so easy, when just a while ago my head was about to expload ahah
Haha I can’t pronounce tweeting sometimes ;) I love your videos. Thanks so much for enlightening us, the new learners.
Thanks man its working for a noob like me
Very nice, easy to understand tutorials. Thanks a lot Sir :)
really good videos, thanks a lot.
thanks. really very interesting teaching approach very deliverable
dude please make a full course about JavaScript
I am getting this error message and I am unsure why
SyntaxError: Unexpected token (
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
I get this error when i try to post/get anything
{ errors: [ { code: 215, message: 'Bad Authentication data.' } ] }
is there a way to solve it.
My bad guys it worked , there was a whitespace in my comsumer key..
11:51 Dan going into full Rick mode for a sec
var Twit = require('twit'); which file of this . when i run this file then show error require this file.
wonderful set of tutorials... so is there a way of creating a bot that analyses all the people you follow and then 5 to 10 of their most liked / retweeted (interacted with) Tweets... ?
Hi, How we can make a new twitter chat boat using new twitter webhooks?
Yeah my bot broke when these changes occurred and I couldn’t get it working again. :/
Codin Grainbow cannot be unheard
Very well explained 👍👍👍
Thank you
I get error code 403 when linking postman through barer code key and single tweet. Does this video just have old instructions?
love the way you teach!
what video shoul i watch to learn how to manipulate the data that we are getting back with an GET request? Thank You.
You are LEGITNESS ! :)
+Victor Catalin Torac These videos may help: th-cam.com/play/PLRqwX-V7Uu6a-SQiI4RtIwuOrLJGnel0r.html
looks like twit lib is no longer being maintained. should I use a different one?
Oh no! Can anyone help? I'll look into it.
The Coding Train the twitter library looks like it has most recent activity.
Thank you for making this! :)
Hi everybody, I had a bot up and running about two years ago using this (great) tutorial series.
I've tried to do it again but now realise that it won't work as Stream has been depreciated..has anyone any suggestions for alternatives?
My bot was set up so as to tweet automatically when a certain twitter account tweeted.
Thanks
i want to make a plugin twitter plugin for wordpress. So do i need to Authenticate every time for searching a defferent tweet. And because the plugin will be used in different url's, what i should do when assigning a new application in my twitter dev account.
How come when he passes the tweeted function into the t.post there is no arguments despite the tweeted function having 3 parameters of err, data, response ?
Best idea for a bot ever!
Hi Daniel, I'm looking to take the data I get from the 'GET' function, and display it in a really nice way, other than the console. Any ideas how I go about this?
Write to file and use that in another program? hmmm...
Thanks for the videos!
I want to create bookmarklet alert to put my token to login to my twitter.. is it possible?
Love this! 🌈
How do I later get Heroku to see the config.js, but keep the keys hidden from GitHub?
who's watching this video in 2115?
01001001001000000110000101101101
hello could you advise if this tutorial is still valid? followed but got stuck on error: The bot is startng
C:\Users\XXX\Documents\twit
ode2
ode_modules\twit\lib\twitter.js:511
throw new Error(err_msg)
^
Error: Twit config must include `consumer_key` when using user auth. my account is active got keys from my dev dashboard?
This is verylate for this post, I'm doing my reasearch to get tweet impressions/analytics. is it possible?
Hey there, I can't seem to get authenticated when I try the "get" function. Any thoughts? Maybe the API has changed?
Hey Juan. Did you manage to fix the error? I'm getting a "Could not authenticate you" message.
@@rajkane2533 hello, could You managed it ?
@@SebastianOspinaHD No :/
@@rajkane2533 i use Twitter Oauth php library and can do it!!
@@SebastianOspinaHD great, I'll check that out. Thanks!
I love your videos man!!!
Cheers!! from Perú
Thank you!
The Twitter API does not let access now without authentication, so I get this error saying bad authentication request. I guess a little too many people made these Twitter bots xD
very good job. thank you.
Good job ! I will try it! :)
You only can post with your user. How can I post with any user/pass?
It possible to search for a specific tag in a certain location. For example 'apple pie' in new york?
+Shahriyar Mahbub Indeed, you combine parameters in a search, something like:
var stream = T.stream('statuses/filter', { q: 'mango', locations: [ '-122.75', '36.8', '-121.75', '37.8' ]})
Why doesn't he have to list the (err, data, response) arguments for the tweeted function?
I get this message on console.log
{ errors: [ { code: 32, message: 'Could not authenticate you.' } ] }
I am using github.com/ttezel/twit
version : 2.2.4
my config.js
module.exports = {
consumer_key: 'XXX ',
consumer_secret: 'XXX',
access_token: 'XXX',
access_token_secret: 'XXX'
}
I have used all the correct keys/tokens
also in this dev.twitter.com/overview/api/twitter-libraries
doc recommends
TwitterJSClientby @BoyCook - Twitter client library written in Javascript and packaged as a node moduleuser-streamby @AivisSilins - a simple Node.js User streams client
I don't know where I went wrong or what i am missing
Please help!
Thanks!
This Is may be because of the white-space. when you copy the consumer key from twitter application settings. Make sure there are no white-space in the beginning and at the end of the keys in your javascript code, when you place all the secret keys between two single quotes (' ').
hey, i got a message error : bad authentication data, how can i solve this ?
I have made a get() twitter bot based on a keyword but the tweets I am getting back are truncated, is there anyway to fix this?? thank you!
how to access whole profile using twit?
great code. can we use this to implement a generic api call to an outh2 end point using the client credential grant? your videos are very fun and insightful. i can give you more info if you want to take a hack at the open template
Hi Daniel, i did exactly same as you do but i get error in "" for (var i = 0; i < tweets.length; i++) { ""
i am using window cmd and twit v 2.2.5
please tell me the solution as soon as possible
same here
did you figure it out?
hey bro, did you figure it out
I think this is happening because the Twitter API now requires all accesses to have authentication, even for accessing data that is public
I changed permissions on "Read, write, and direct messages" on Twitter Application Management
Hi, How can i make a GET user/search twitter request from react native?, I'm going crazy with OAuth 1.0a
i have got this error messages:{
Error: ETIMEDOUT
at Timeout._onTimeout (/Users/local/Documents/project/nodeDemo/node_modules/request/request.js:813:19)
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5)
code: null,
connect: true,
statusCode: null,
allErrors: [],
twitterReply: ''
},so i can't post or get a message from twitter. -_-
Thanks for this video. I was wondering, how do you authenticate for other users in order to allow my app to get that user's tweets. Thanks in advance
Do you need a developer account with Elevated access to be able to get the tweets from twitter?
I don't believe so but the Twitter API is a moving target. I hope to be able to revisit and update these videos soon!
I get to comment first on your videos mostly. Great tutorials .
I have encountered a problem, which I think maybe platform related. When I run code via powershell in windows, it doesn't get executed. But now I have uploaded the code to the cloud9 online platform, and It works fine.
Do you have any idea about this?
+deepank verma I'm not sure. Here is a tutorial about node and windows that might help? blog.falafel.com/getting-started-with-nodejs-for-windows/ Let me know!
+Daniel Shiffman My node is working correctly, but I think there is problem with
connecting to API. That's may be because I'm behind institution's proxy.
Just guessing.
+deepank verma Did you run your script with sudo?
Tyler Swartzenburg no, but I'm not on Linux.
How do you follow someone with Twit? There's a whole example function in one of the included bots that follows a random follower, but when I tried to integrate it, it does nothing. No errors. Nothing. My list of people I follow doesn't change.
Also: I managed to get a list of user_id's from another Twit function, but it's not an array. It's just a collection of data spouted all together. How do I make it an array I can plug into other functions?
So did he cover streaming? I can't seem to find it anywhere in this video?
Hey Daniel! Do you know if it'd be possible to search for users within a specific area with a following of over X amount? (ie people in London with over 20,000 followers). Cheers again
+adjo.co.uk you can definitely search for tweets by location (dev.twitter.com/rest/reference/get/search/tweets), the user search doesn't seem to have this as an option (dev.twitter.com/rest/reference/get/users/search). I might write an app that compiles this list by listening to the public timeline of a location for a long time. . you would get a lot of active users and then you could filter yourself by followers.
+Daniel Shiffman Thank you for the tutorial Daniel. However, I have an issue, how can I get a tweet that I have been mentioned on and post the same tweet using my account??
I need a way in which I can get both the screen_name and statuses.text of the person who mentions me.
Like example::::
ABC: Hello @Daniel hi. // ABC is the person who mentioned you @Daniel
Daniel: Hello @Daniel hi. -via @ABC //This is the tweet that your account posts.
Thank you in advance
Hi, i am getting an error @ 8:35
throw new Error(err_msg)
^
Error: Twit config must include `access_token_secret` when using user auth.
But i copy and pasted the CORRECT access_token_secret, and it contains no white spaces. Any suggestions?
Thanks in advance
Where is previous video ?
Sir if anyone twit and I want her twit in 1-2 second , so it is possible with api or not? For example Elon Musk make twit and I want newly twit in 1 second through api. Please tell me
Is it possible to search for specific keywords on tweets and the author's username and location and tweet URL will be returned?
+Jayrell Recido yes, all of that metadata comes back in the "data" object.
Error
the bot is starting
/home/ubuntu/workspace/prueba/bot2.js:6
var T = new Twit(config);
^
ReferenceError: Twit is not defined
at Object. (/home/ubuntu/workspace/prueba/bot2.js:6:13)
i dont get a "manage your app" in twitter developer page.
shall you tell me another way to get my access tokens??!!!
go to apps.twitter.com
I had to stringify the json :/
How do I access the data outside the gotData function?
This posts a tweet to the twitter handle associated with the developer account. How can I post to a different twitter account of mine from the developer account?
I figured this out. I think I'll post a tutorial on it soon
hey Daniel, i'm working on making a project using the twitter Get API.
How would you recommend getting the JSON data over from from terminal to a file I could use?
Take a look at the fs (file system) package in node.