Twitter API + Bot start

This commit is contained in:
Manuel Hude
2021-05-02 10:45:01 +02:00
parent e90ae52267
commit 0a212a6a65
9 changed files with 18559 additions and 26 deletions
+18436 -22
View File
File diff suppressed because it is too large Load Diff
@@ -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),
+10
View File
@@ -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);
}
}