Tweet Migration is a 3D visualization of tweets.
- Fork or clone this repo
git clone git@github.com:Yonet/AzureTweetMigration.git
- Create local.settings.json file at the root level of your project. If you follow the steps-0, this file will be automatically created for you.
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "node"
}
}
- Install dependencies
npm install
- Run npm start script
npm run start
In this step, we will setup our project and create an Azure Function to get Twitter Search data into our application. You can follow the below steps or check out "step-0" branch of this repo.
- Download
-
Node.js latest LTS version. Latest Node is not compatible with the tools we are using and not recommended for most users.
-
Visual Studio Code Azure Extensions or Azure Functions Extension
- Sign up for a free Azure account
-
Select Azure Extensions from VS Code left hand panel.
-
Select Functions grouping, click on folder icon on the Functions grouping to create a new project. Select a folder or create a new folder for your project repository.
-
To create a function select the second icon on the Functions grouping.
-
You will be prompted to sign in if you have Azure Tools or Azure Repos extensions.
-
When prompted, name your function "SearchTweets". Language "TypeScript".
-
When prompted, select "Anonymous". This will make our API public.
-
Azure Functions Extension will create our initial configuration files as well as SearchTweet folder with our first Azure function.
-
To run the code you can open up the internal terminal from the Command Palette (⇧⌘P), use the View: Toggle Integrated Terminal command.
-
Run npm start script
npm run start
-
Start script will download extensions configured in your 'functions.json' file and start a serve your project.
-
In your terminal, you will see a localhost link 'http://localhost:7071/api/SearchTweets'. Click the link to open in a browser.
-
You will see the error message being displayed. This message is set on 'SearchTweet/index.ts' file.
-
Add a name query value to see the message returned.
http://localhost:7071/api/SearchTweets?name=aysegul
Adding Twitter Api: we will add twitter authorization and search functionality. We will refactor our code to make sure when the our projects gets bigger, it is still maintainable and structured well.
-
Sign up for Twitter Developer Api
-
We will be using the standard search api. Add tokens and secrets as well as the search url we will be calling to local.settings.json file.
{
"consumer_key": "fs54YbjfXuQWJRs01XatGR",
"consumer_secret": "lzXoL4GzxGYeItJ327BGcNmZcmPhgjgft62x0tHuZYmad",
"access_token_key": "35870660-0250Io0UYm5NHtutgM7bq57h9aChvA30FIBYV0j1q",
"access_token_secret": "RFab22sgMgg9DlwoWRZrQRIizQZultYvo2Ek9C0Xp",
"search_url": "https://api.twitter.com/1.1/search/tweets.json"
}
You can add your keys in any other structure if you like. I can reach to my keys from my functions as:
process.env.Twitter.consumer_key;
- Authentication: we will use application-only authentication. Application-only authentication offers applications the ability to issue authenticated requests on behalf of the application itself (as opposed to on behalf of a specific user). We need to acquire bearer token using our consumer key and secret.