Giter Site home page Giter Site logo

react-native-twitter's Introduction

react-native-twitter

A Twitter API client library for React Native

Installation

npm i react-native-twitter -S
react-native link

If you use 3-legged authorization, you need to add the deep link scheme for your callback URL. See React Native docs and example for more info.

Usage

import twitter, {auth} from 'react-native-twitter';

auth(tokens, callbackUrl[, options])

Get the client's authentication tokens via 3-legged authorization.

  • tokens

    • consumerKey Your consumer key
    • consumerSecret Your consumer secret
  • callbackUrl The URL a user is redirected to, you need to add the deep link scheme for this URL

  • options

  • Returns: Promise of {accessToken, accessTokenSecret, id, name}

    • accessToken Access token
    • accessTokenSecret Access token secret
    • id User id
    • name Screen name

auth(tokens, pinPromise[, options])

Get the client's authentication tokens via PIN-based authorization.

  • pinPromise Promise which resolves to PIN

  • Returns: Promise of {accessToken, accessTokenSecret, id, name}

const client = twitter(tokens)

Create a Twitter API client.

  • tokens
    • consumerKey Your consumer key
    • consumerSecret Your consumer secret
    • accessToken Access token
    • accessTokenSecret Access token secret
const {rest, stream} = twitter(tokens);

rest.get(path[, params])

Make GET requests.

  • path The endpoint path

  • params Parameters for the request

  • Returns: Promise

rest.post(path[, params])

Make POST requests.

  • path The endpoint path

  • params Parameters for the request

  • Returns: Promise

There is no File or Blob in React Native, but you can use Object with uri property as media files for media uploading endpoints such as account/update_profile_image. Below is an example of changing profile image to the latest photo from CameraRoll.

CameraRoll.getPhotos({first: 1})
  .then(({edges: [{node: {image}}]}) => rest.post('account/update_profile_image', {image}))
  .then(() => {console.log('done');})
  .catch(console.error);

stream(path, params) (Android only)

Connect to Streaming APIs.

  • path The endpoint path

  • params Parameters for the request

  • Returns: EventEmitter

    • 'data'
    • 'error'
    • close() Close the connection

react-native-twitter's People

Watchers

 avatar  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.