ng2-twitter

Angular2 service of authorized request for twitter.

This package is no longer maintained.
Last updated 3 years ago by aoinu .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ng2-twitter 
SYNC missed versions from official npm registry.

#ng2-twitter Angular2 service of authorized request for twitter.

##Installation Install through npm:

npm install --save ng2-twitter

##Usage

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';
import { TwitterService } from 'ng2-twitter';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule
  ],
  providers: [TwitterService], // Add
  bootstrap: [AppComponent]
})
export class AppModule { }
import { Component } from '@angular/core';
import { TwitterService } from 'ng2-twitter';

@Component({
  selector: 'app-root',
  template: `
		<h1>{{title}}</h1>
		<button (click)="getHomeTimeline()">get/home_timeline</button>
		<p>{{result}}</p>
	`
})
export class AppComponent {
  title = 'app works!';
  result = '';
  constructor(private twitter: TwitterService){ }

  getHomeTimeline(){
    this.twitter.get(
      'https://api.twitter.com/1.1/statuses/home_timeline.json',
      {
        count: 5
      },
      {
        consumerKey: 'consumerKey',
        consumerSecret: 'consumerSecret'
      },
      {
        token: 'token',
        tokenSecret: 'tokenSecret'
      }
  ).subscribe((res)=>{
      this.result = res.json().map(tweet => tweet.text);
  });
  }
}

##Note In Web browser, JavaScript application cannot access external domain server because of Cross-Origin Resource Sharing.

This service supposes to be used in Cordova, Electron, Chrome Extensions or web security disabled browser.

Current Tags

  • 0.3.0                                ...           latest (3 years ago)

3 Versions

  • 0.3.0 [deprecated]           ...           3 years ago
  • 0.2.0 [deprecated]           ...           3 years ago
  • 0.1.0 [deprecated]           ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (6)
Dev Dependencies (1)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |