Twitter API + Bot start
This commit is contained in:
@@ -2,6 +2,10 @@ import { Component, OnInit } from '@angular/core';
|
||||
import {AuthService} from '../../services/auth.service';
|
||||
import {HttpClient, HttpHeaders} from '@angular/common/http';
|
||||
|
||||
class Tweet {
|
||||
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-tweets',
|
||||
templateUrl: './tweets.component.html',
|
||||
@@ -9,6 +13,8 @@ import {HttpClient, HttpHeaders} from '@angular/common/http';
|
||||
})
|
||||
export class TweetsComponent implements OnInit {
|
||||
|
||||
tweets:Tweet[] = [];
|
||||
|
||||
constructor(private http: HttpClient,
|
||||
private authService: AuthService) { }
|
||||
|
||||
@@ -16,10 +22,13 @@ export class TweetsComponent implements OnInit {
|
||||
}
|
||||
|
||||
loadMore() {
|
||||
console.log('TODO: Implement');
|
||||
|
||||
const headerDict = {
|
||||
'Authorization': 'Bearer ' + this.authService.getToken(),
|
||||
};
|
||||
|
||||
|
||||
|
||||
return this.http.get('http://localhost:8000/api/login',
|
||||
{
|
||||
headers: new HttpHeaders(headerDict),
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
import {Observable} from 'rxjs';
|
||||
import DateTimeFormat = Intl.DateTimeFormat;
|
||||
|
||||
export interface WSEvents {
|
||||
message: Observable<Event>;
|
||||
error: Observable<Event>;
|
||||
close: Observable<Event>;
|
||||
}
|
||||
|
||||
export interface Tweet {
|
||||
|
||||
icon: any
|
||||
text: string
|
||||
date_time: DateTimeFormat
|
||||
url: String
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Injectable} from '@angular/core';
|
||||
import {NGXLogger} from 'ngx-logger';
|
||||
import {environment} from '../../environments/environment';
|
||||
import {Observable} from 'rxjs';
|
||||
import {Tweet} from "../interfaces/interface";
|
||||
|
||||
@Injectable()
|
||||
export class TwitterService {
|
||||
private currentLocation = 'http://' + environment.location + ':' + environment.port + '/';
|
||||
|
||||
constructor(
|
||||
private logger: NGXLogger,
|
||||
private http: HttpClient
|
||||
) {
|
||||
}
|
||||
|
||||
getSixTweets(): Observable<Tweet[]> {
|
||||
const url = this.currentLocation + 'getSixTweets/';
|
||||
this.logger.debug('Performing get Six Tweets');
|
||||
return this.http.get<Tweet[]>(url);
|
||||
}
|
||||
|
||||
getTwelveTweets(): Observable<Tweet[]> {
|
||||
const url = this.currentLocation + 'getTwelveTweets/';
|
||||
this.logger.debug('Performing get Twelve Tweets');
|
||||
return this.http.get<Tweet[]>(url);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user