Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/avinashreddy1010/twitter_api_assignment

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/avinashreddy1010/twitter_api_assignment

  • v0.0.0-20241010200752-1a67748290a2
  • Source
  • Go
  • Socket score

Version published
Created
Source

Twitter API Interaction with Go

Introduction

This project demonstrates how to interact with the Twitter API using the Go programming language. It focuses on creating and deleting tweets while handling OAuth 1.0a authentication. Below are done in this assignment.

  • Set up and use the Twitter API.
  • Authenticate using OAuth 1.0a in a Go program.
  • Post a tweet programmatically.
  • Delete a tweet using its unique ID.
  • Handle errors such as invalid credentials or invalid tweet IDs.

Setup Instructions

Set Up a Twitter Developer Account

  1. Go to the https://developer.x.com/en and log in with your twitter account.
  2. Apply for a developer account.
  3. Create a project and an app in the developer account.

Generate API Keys

Once App is created, we have to generate the Keys and Tokens.

  1. Copy Consumer Key and Consumer Secret in API Key and Secret
  2. Copy Access Token and Access Token Secret in Access Token and Secret
  3. Generate and Copy the Bearer Token
  4. The tokens and secrets are defined in the .env file in our code.

Program Details

Our code lets us create a new tweet by sending a POST request, When executed a tweet with the current timestamp is sent. Please find below screenshot. alt text

We can delete the tweet by providing tweetID. Upon successful deletion, a confirmation message is displayed.

We need to execute go run main.go if we want to run the application. Our tweet will be posted once we run main.go If we want to delete the tweet, we need to provide TweetID which we want to delete. alt text

FAQs

Package last updated on 10 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc