Options
All
  • Public
  • Public/Protected
  • All
Menu

PlurkClient is a class that wraps all plurk API call and handles comet channel when enabled. It inherits from Node.js's EventEmitter class.

Hierarchy

  • internal
    • PlurkClient

Implements

Index

Constructors

constructor

  • new PlurkClient(consumerKey: string, consumerSecret: string, token?: string, tokenSecret?: string): PlurkClient
  • Constructor

    Parameters

    • consumerKey: string

      Consumer token, can be obtain one from Plurk App console.

    • consumerSecret: string

      Consumer token secret, should be together with consumer token.

    • Default value token: string = ""

      Oauth access token, optional. You may assign it here or use getRequestToken() and then getAccessToken() to obtain one from user with oauth authentication flow.

    • Default value tokenSecret: string = ""

      Oauth access token secret, optional. Also this should be come with access token.

    Returns PlurkClient

Properties

cometStarted

cometStarted: boolean

Flag indicates if the commet channel is started.

consumerKey

consumerKey: string

Consumer token, can be obtain one from Plurk App console.

consumerSecret

consumerSecret: string

Consumer token secret, should be together with consumer token.

stopCometOnError

stopCometOnError: boolean

Boolean field, set to true to automatic stops the comet channel when any error has been thrown, or else it will keep reconnect even have errors.

token

token: string

OAuth access token or request token of current client.

tokenSecret

tokenSecret: string

OAuth token secret of current client.

Accessors

authPage

authPage:

User authentication URL. Should be inform user to navigate to this URL once the promise of getRequestToken(...) has been resolved.

mobileAuthPage

mobileAuthPage:

Mobile version of user authentication URL. Users may navigate to this URL instead of authPage if they are using smartphones.

Methods

addListener

  • addListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

getAccessToken

  • getAccessToken(verifier: string): Promise<this>
  • Get oauth access token (permanent) for requesting other API. It will assigns token and tokenSecret of current instance. Should be called once users' verifier has been received.

    Parameters

    • verifier: string

      The oauth verifier received from the user.

    Returns Promise<this>

    Current plurk client instance.

getMaxListeners

  • getMaxListeners(): number
  • Returns number

getRequestToken

  • getRequestToken(callback?: string): Promise<this>
  • Get oauth request token (temporary) for user to authenticate. It will assigns token and tokenSecret of current instance for further process.

    Parameters

    • Default value callback: string = ""

      Redirect URL after authenticate success, can be omitted if this is not a web app.

    Returns Promise<this>

    Current plurk client instance.

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

on

  • on(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

pollComet

  • pollComet(): void
  • Restart long poll from comet channel. Normally this method is automatically called while polling.

    Returns void

prependListener

  • prependListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

request

  • request(api: string, parameters?: any): Promise<any>
  • Make a post request API call to Plurk (as recommended in the documentation), it will uses the oauth token provided in the client instance if available. Plurk API Reference

    Parameters

    • api: string

      API path as written in the documentation. APP/ prefix can be omitted.

    • Optional parameters: any

      Object hash of the parameters, can be omitted if no parameters. Also it will automatically converts Date object entries to ISO8601 string and Array object entries to JSON string before request. You may also pass Node.js native Buffer or Stream values for image uploading APIs such as /APP/Timeline/uploadPicture.

    Returns Promise<any>

    The parsed JSON data respond from Plurk. It will auto converts all known date/time fields to Date objects and limited_to field to array of numbers.

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

startComet

  • startComet(): void
  • Start long poll from comet channel, it auto handles request for comet server URL and it will auto keep polling until you stops it.

    Returns void

stopComet

  • stopComet(): void
  • Stops long poll from comet channel.

    Returns void

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc