Editing Intro to Programming and Data Science (Summer 2021)/Twitter authentication setup

From CommunityData

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 11: Line 11:
Follow each of these steps:
Follow each of these steps:


'''1.''' Sign in to Twitter and go to the Twitter development homepage: https://developer.twitter.com/en/portal/petition/use-case
'''1.''' Go to the Twitter development homepage: https://developer.twitter.com/


'''2''' Choose "Academic" and then "Student" for the two options, and then "Get Started".
'''2.''' If you're not already signed in to Twitter, click on '''Sign In''' in the top right corner of the page. You can sign in with your normal Twitter account. (It may take you to your Twitter home page when you sign in. If so, return to https://developer.twitter.com/ once you're logged on.)


[[File:Twitter_signup.png|400px]]
'''3.''' Click on the [https://developer.twitter.com/en/apply-for-access "Apply" link] (https://developer.twitter.com/en/apply-for-access). The link should be located in the top right of the page beside "Apps" and your Twitter icon.


'''3''' On the next page, under "what would you like us to call you", put "Purdue_student" (or use your name if you'd like). Enter your location as United States, and your coding experience as "No experience".
'''4''' Click "Apply for a Developer Account" in the middle of the page.


'''4''' Next, Twitter will ask you about your plans. ''Please follow these instructions carefully to make sure Twitter approves your application.''
'''5''' The next page asks "What is your primary reason for using Twitter developer tools?" and gives you a lot of options. ''Click Student'', which is in the third column.
 
'''6''' On the next page, under "what would you like us to call you", put "Purdue_student" (or use your name if you'd like).
 
What you are signing up for is an Individual Developer Account (as opposed to Team Developer Account).
 
 
'''7''' Next, Twitter will ask you about your plans. ''Please follow these instructions carefully to make sure Twitter approves your application.''


In the field "In your words" put something like the following:
In the field "In your words" put something like the following:


     I am taking an Introduction to Programming and Data Science course at Purdue university. My instructor is Jeremy Foote (jdfoote@purdue.edu). You can find details about the course at https://wiki.communitydata.science/Intro_to_Programming_and_Data_Science_(Summer_2021).
     I am taking an Introduction to Programming and Data Science course at Purdue university. My instructor is Jeremy Foote (jdfoote@purdue.edu). You can find details about the course at https://wiki.communitydata.science/Intro_to_Programming_and_Data_Science_(Summer_2020).


Under "The Specifics" check yes for "Are you planning to analyze Twitter data" and enter the following text:
Under "The Specifics" check yes for "Are you planning to analyze Twitter data" and enter the following text:
Line 35: Line 42:




'''5''' Click "next" in the lower right then click "Next" on the review page. Finally, accept the Developer Agreement and click "Submit Application" on the next page.
'''8''' Click "next" in the lower right then click "Looks good" on the review page. Finally, accept the terms of service and click "Submit Application" on the next page.
 




'''6''' Twitter may send an email to the account you used. Click "Confirm your email" in that email to finish setup.
'''9''' Twitter will send an email to the account you used. Click "Confirm your email" in that email to finish setup.






'''If you have any trouble with the steps before this, ask for help ASAP'''
'''If you have any trouble with the steps before this, email me ASAP'''


== Confirm your developer email address  ==
== Confirm your developer email address  ==


'''7''' When you confirm in the email, you will arrive at https://developer.twitter.com/en/portal/projects-and-apps. On that page, click "Create app" under "Standalone Apps".
'''10''' When you confirm in the email, you will arrive at https://developer.twitter.com/en/account/get-started. On that page, click "Create an app". This will take you to https://developer.twitter.com/en/apps


'''8''' Give your app a name
'''11''' Click "Create an app", which takes you to https://developer.twitter.com/en/apps/create. You'll need to fill in a few details about your app.


App name: "COM 674 Sample <Your_First_and_Last_Name>"
App name: "COM 674 Sample <Your_First_and_Last_Name>"


and click next.
Application Description: "Sample application for COM 674."
 
Website: "https://www.example.com"
 
Callback URLs: "https://www.example.com"


Leave "Enable Sign in with Twitter" unchecked.
The next few fields are not needed, but scroll to the bottom to find "Tell us how this app will be used".
Tell us how this app will be used: "Learning data science with python in COM 674 at Purdue University. This app is for testing purposes only."
Finally, click create, and click create again in the modal window.
*Almost there!!*


== Generate and copy your individual, private, unique Twitter developer credentials ==  
== Generate and copy your individual, private, unique Twitter developer credentials ==  
 
'''12''' In the next step, you will access Twitter credentials, which will let you authenticate with Twitter in python.
'''9''' In the next step, you will access Twitter credentials, which will let you authenticate with Twitter in python.


You need unique, private credentials to collect tweets. You will be pasting these credentials into your Python code. Be sure if you share your Python code, you ***do not** share your unique developer credentials.  
You need unique, private credentials to collect tweets. You will be pasting these credentials into your Python code. Be sure if you share your Python code, you ***do not** share your unique developer credentials.  


When you created your app, it should have generated the Consumer API and API secret keys. These are two long strings labeled "API key" and "API secret key". You should copy and paste those into a text file on your desktop.
Click the "Keys and Tokens" tab. You will see a box called "Consumer API keys" with two long strings labeled "API key" and "API secret key". You should copy and paste those into a text file on your desktop.


'''10''' Click the name of your app on the left-hand side and then click "Keys and tokens" on the top. Finally, click "Generate" under "Access Token and Secret". This will open a modal with two new strings called "Access Token" and "Access Token Secret". Copy these two keys to the same file and close the modal.
Finally, click "Generate" which will open a modal with two new strings called "Access Token" and "Access Token Secret". Copy these two keys to the same file and close the modal.
 
[[File:access_token.png|400px]]


You will need all four of these strings in order to have your Twitter application work.
You will need all four of these strings in order to have your Twitter application work.


'''Keep this material secret.''' Your access token and access token secret will allow anybody who has it to post to Twitter as you and to control your account. It is equivalent to your Twitter username and password so please be as careful with it as you would be with your Twitter password! If you accidentally let it out into the world, then go to your application's key's and tokens page and "Regenerate" all of the tokens. This will invalidate the old ones (like resetting your password).
'''Keep this material secret.''' Your access token and access token secret will allow anybody who has it to post to Twitter as you and to control your account. It is equivalent to your Twitter username and password so please be as careful with it as you would be with your Twitter password!


== Other documentation ==
== Other documentation ==
'''Note that some of these links may be outdated as Twitter begins to move to v2 of the API. Feel free to edit the wiki to update them'''
Explore how Tweets are structured  
Explore how Tweets are structured  


Line 88: Line 103:


This page has some helpful intel about modifying Standard Search parameters (including sample request and response):
This page has some helpful intel about modifying Standard Search parameters (including sample request and response):
* [https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/api-reference/get-search-tweets Getting search tweets.]
* [https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets Getting search tweets.]


Using the Twitter Realtime API :  
Using the Twitter Realtime API :  
Please note that all contributions to CommunityData are considered to be released under the Attribution-Share Alike 3.0 Unported (see CommunityData:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel Editing help (opens in new window)