
Security News
TC39 Advances 11 Proposals for Math Precision, Binary APIs, and More
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
react-native-twitter
Advanced tools
A Twitter API client library for React Native
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.
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 keyconsumerSecret
Your consumer secretcallbackUrl
The URL a user is redirected to, you need to add the deep link scheme for this URL
options
accessType
Specify x_auth_access_type
, supported values are 'read'
or 'write'
(See Twitter docs.)forSignIn
If true
, oauth/authenticate endpoint is used instead of oauth/authorize (Default: false
)forceLogin
Specify force_login
(See Twitter docs.) (Default: false
)screenName
Specify screen_name
(See Twitter docs.)Returns: Promise
of {accessToken, accessTokenSecret, id, name}
accessToken
Access tokenaccessTokenSecret
Access token secretid
User idname
Screen nameauth(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.
consumerKey
Your consumer keyconsumerSecret
Your consumer secretaccessToken
Access tokenaccessTokenSecret
Access token secretconst {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 connectionFAQs
react-native-twitter
We found that react-native-twitter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.