Coder Social home page Coder Social logo

tweet's Introduction

๐Ÿฆ Tweet with Twitter!

Lambda for simply sending a tweet upon post using Netlify's Functions capabilities.

โšก Quick Start

Deploy to Netlify

  • Deploy to Netlify (use button above)
  • Add a unique key as your APP_SECRET under Settings > Build & Deploy > Environment
  • Once deployed, you're ready to get started!

Your function should now be avialable at:

https://[your-netlify-site].netlify.com/.netlify/functions/tweet

๐Ÿš€ Posting to Endpoint

Authorization Header

When posting to the endpoint, you'll need to generate a JWT given the same APP_SECRET as above. The contents of the JWT before signed should look like:

{
  twitter_consumer_key: [key],
  twitter_consumer_secret: [key],
  twitter_access_token_key: [key],
  twitter_access_token_secret: [key],
}

You can use libraries such as Auth0's JsonWebToken to generate within your app: https://github.com/auth0/node-jsonwebtoken

Pass this as an Authorization header

Content

The body of the post should look like the following:

{
  "description": "[text of tweet]",
  "link": "[tweet link appended to status]",
  "image": "[tweet image (optional)]",
}

โš’๏ธ Local Setup

Install Dependencies

To begin setup, with a newly cloned repo:

yarn install

Env

Create a local .env file at the root of the project with the shared secret. This is used in coordination with JWT to create token containing your Twitter keys that gets posted to this function endpoint.

APP_SECRET="[secret]"

Run it Locally

To test this locally, run:

yarn serve

The function should now be available at localhost:9000/tweet

tweet's People

Contributors

colbyfayock avatar dependabot[bot] avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.