Skip to content

Yonet/AzureTweetMigration

Repository files navigation

AzureTweetMigration

Tweet Migration is a 3D visualization of tweets.

How to run

  1. Fork or clone this repo
git clone git@github.com:Yonet/AzureTweetMigration.git


  1. 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"

}
}
  1. Install dependencies
npm install
  1. 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
  • 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 # 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

Step-1

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.

{
    "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.

Auth