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

twittercordovaplugin

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

twittercordovaplugin

An Apache Cordova plugin for the Twitter Streaming API. Currently only works for Android.

  • 0.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

Twitter Streaming Cordova Plugin

This is a quick Apache Cordova plugin to use the Twitter Streaming APIs within a hybrid mobile application. It uses the twitter4J Java code

Dependencies

  • org.apache.cordova.inappbrowser http://plugins.cordova.io/#/package/org.apache.cordova.inappbrowser
  • jsOAuth
  • Twitter4J

Dependencies are installed automatically. There are no configuration steps that are required by the user.

#Supported Platforms

  • Android

This Cordova plugin only works for Android at this time

#Installing Install with Cordova CLI

$ cd /path/to/your/project $ cordova plugin add com.lisaseacat.twitter

API

Methods

init

Intialize the metawear device.

twitter.init(successCallback, failureCallback, oauthconsumerkey, oauthconsumersecret, callbackURL);

Description

Function 'init' initializes the twitter streaming service. This method attempts to connect to twitter. It uses the inappbrowser plugin to ask the user to authorize the app to use Twitter. On successful authorization it will automatically start listening for tweets with a specific hashtag. The success callback is called when a new tweet is found matching the keyword. To set the keyword use the sethashtag method. You will need to setup a Twitter app at https://apps.twitter.com/.

Parameters

  • successCallback: Success callback function that is invoked when twitter is authorized by the user through oAuth and a message is received.
  • failureCallback: Error callback function, invoked when error occurs.
  • oauthconsumerkey: The oauth consumer key that was setup in the Twitter API developer console.
  • oauthconsumersecret: The oauth consumer secret that was setup in the Twitter API developer console.
  • callbackURL: The oauth callback URL that was setup in the Twitter API developer console. It doesn't matter what this value is. It's not used in Cordova, but necessary for OAuth to work.
  • keyword: The keyword to listen for. You can change the keyword at any time by calling addHashtag. [optional]

stopTwitterStream

twitter.stopTwitterStream(successCallback, failureCallback) 

Description

Function 'stopTwitterStream' tells the twitter stream to stop listening. To start it back up after it has been stopped you'll have to call init again.

Parameters

  • successCallback: Success callback function that is invoked when the twitter stream was successfully stopped.
  • failureCallback: Error callback function, invoked when error occurs.

addHashtag

twitter.addHashtag(successCallback, failureCallback, keyword, reset) 

Description

Function 'setHashTag' tells the twitter stream which keyword to listen for.

Parameters

  • successCallback: Success callback function that is invoked when the twitter stream was successfully stopped.
  • failureCallback: Error callback function, invoked when error occurs.
  • keyword: The keyword to listen for. You can change the keyword at any time by calling this method again.
  • reset: boolean. By setting to true, the old hashtag value will be cleared out. If set to false, the streaming search will look for ALL of the previous keywords as well as the new keyword. Default value is false. [optional]

getHashtag_NoStream

twitter.getHashtag_NoStream(successCallback, failureCallback) 

Description

Function 'getHashtag_NoStream' lets you retrieve hashtags from Twitter without using the streaming service. There is a rate limit set by Twitter to use this method..

Parameters

  • successCallback: Success callback function that is invoked when the response is received. Unlike the streaming service you will have to call this method multiple times each time you wish to receive the information.
  • failureCallback: Error callback function, invoked when error occurs.

getHomeTimeline_NoStream

twitter.getHomeTimeline_NoStream(successCallback, failureCallback) 

Description

Function 'getHomeTimeline_NoStream' lets you retrieve the home timeline from Twitter without using the streaming service. There is a rate limit set by Twitter to use this method..

Parameters

  • successCallback: Success callback function that is invoked when the response is received. Unlike the streaming service you will have to call this method multiple times each time you wish to receive the information.
  • failureCallback: Error callback function, invoked when error occurs.

getMentions_NoStream

twitter.getMentions_NoStream(successCallback, failureCallback) 

Description

Function 'getMentions_NoStream' lets you retrieve hashtags from Twitter without using the streaming service. There is a rate limit set by Twitter to use this method..

Parameters

  • successCallback: Success callback function that is invoked when the response is received. Unlike the streaming service you will have to call this method multiple times each time you wish to receive the information.
  • failureCallback: Error callback function, invoked when error occurs.

Quick Example

var streamtweet = {
    consumerKey: '__replaceMe__',
    consumerSecret: '__replaceMe__',
    callbackUrl: '__replaceMe__',
    start: function() {
        console.log('streamtweet start! ');
        twitter.init(streamtweet.tweetreceived, streamtweet.tweetfailed, streamtweet.consumerKey,streamtweet.consumerSecret,streamtweet.callbackUrl, 'LisaSeacat');
    }, 
    tweetreceived: function(data){
        console.log('SUCCESSFULLY got some streaming tweets: ' + JSON.stringify(data)); 
    }, tweetfailed: function(data){
        console.log('FAILED to get the tweets: ' + JSON.stringify(data));  
    }, tweetStopWin: function(data){
        console.log('SUCCESSFULLY stopped getting tweets: ' + JSON.stringify(data));  
    }, tweetStopFail: function(data){
        console.log('FAILED to stop the tweet stream: ' + JSON.stringify(data));  
    }, stop: function(){
        twitter.stopTwitterStream(streamtweet.tweetStopWin, streamtweet.tweetStopFail);   
    }
};

Keywords

FAQs

Package last updated on 29 Feb 2016

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