Problem Statement
The requirement is to extract the data from Twitter and load the extracted data into SQL Database. For this demonstration, I am going to read the Indian Film actor Kamal Haasan's tweets and load that into SQL Server 2016 Database.
Solution
Let’s see the solution step by step
Step 1
First, we have to install and configure the curl.
“Curl ('Client for URLs') is a tool to transfer data from or to a server, using one of the supported protocols (HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, DICT, TELNET, LDAP or FILE). The command is designed to work without user interaction“
Go to -> https://curl.haxx.se/download.html, download the latest version of Curl software under Win 32 - Generic or Win 64 – Generic based on your Windows OS bit.


Step 2
We don’t need to install the curl because the package is already built. Extract the downloaded zip file and copy curl.exe and ca-bundle.crt, paste that in “C:\Curl” (Create folder wherever you want).

Step 3
We have to setup the Environment variable path for Curl.
Go to My Computer -> Properties -> Advanced system settings -> Advanced -> Environment Variables -> Edit Path under System Variables section.

Click New -> Add the curl.exe folder location.

Run the below command in Windows command prompt to check whether Curl is installed and configured correctly.

Step 4
In order to read data from Twitter application, we have to create App in Twitter, Go to -> https://apps.twitter.com
Prerequisites
- The user should have a Twitter account.
- The user should have provided a mobile number in the Twitter account.
Create App by filling the required fields. If you do not have website details, give https://google.com/ a shot.

Click “Create your Twitter Application” button.
Step 5
Go to "Keys and Access Tokens" tab and note down Consumer Key (API Key) and Consumer Secret (API Secret).

Twitter supports OATH 2.0 Authentication so we have to generate Bearer token. For that, we need to convert API Key and API Secret in Base64 format. Go to https://www.base64encode.org/
Syntax
<Consumer Key (API Key)> : <Consumer Secret (API Secret)>







Bhanu PrakashPosted Nov 21, 2018, 1:10 AM
Can any one help me how can i resolve this, been trying from 2 days ,but not able to figure it out
Bhanu PrakashPosted Nov 21, 2018, 1:09 AM
Curl --compressed "https://api.twitter.com/oauth2/token" --header "Accept-Encoding: identity" --header "Authorization: Basic <Base 64 Code>" ERROR: '-- Header' is not recognized as an internal or external command, operable program or batch file --header "Content-Type: application/x-www-form-urlencoded;charset=UTF-8" --data "grant type=client credentials" ERROR: '-- Header' is not recognized as an internal or external command, operable program or batch file
Bhanu PrakashPosted Nov 21, 2018, 1:04 AM
I have tried the above method as same to handle the twitter data. but while generating the json file getting the below error
Ashok KumarPosted Aug 16, 2017, 5:38 PM
I am getting error in cmd like this err{"errors":[{"code":170,"message":"Missing required parameter: grant_type","label":"forbidden_missing_parameter"}]}
Manav PandyaPosted Aug 16, 2017, 5:19 AM
Can i use same with FB ???
Manav PandyaPosted Aug 16, 2017, 5:19 AM
Nice share ...........
Yashwant VishwakarmaPosted Aug 16, 2017, 4:31 AM
Thank You Brother :)
Yashwant VishwakarmaPosted Aug 16, 2017, 1:54 AM
Awesome article. Could you please ping the command in step 3 ; which you ran in command prompt. I am not able to see that command in screenshot.