|
@@ -2,12 +2,13 @@ import { Injectable } from "@angular/core";
|
|
|
import { HttpClient } from "@angular/common/http";
|
|
|
import { Storage } from "@ionic/storage";
|
|
|
import Twit from "twit";
|
|
|
+import { PgpKeyServerProvider } from "../../providers/pgp-key-server/pgp-key-server";
|
|
|
|
|
|
@Injectable()
|
|
|
export class TwitterApiProvider {
|
|
|
client: Twit;
|
|
|
|
|
|
- constructor(public http: HttpClient, private storage: Storage) {
|
|
|
+ constructor(public http: HttpClient, private storage: Storage, private openpgp: PgpKeyServerProvider,) {
|
|
|
this.initApi();
|
|
|
}
|
|
|
|
|
@@ -15,19 +16,17 @@ export class TwitterApiProvider {
|
|
|
* initialize Twitter API provider
|
|
|
*/
|
|
|
public async initApi() {
|
|
|
- console.log('initAPi iis initting');
|
|
|
const access_token_key = await this.storage.get("accessTokenKey");
|
|
|
const access_token_secret = await this.storage.get("accessTokenSecret");
|
|
|
- console.log('inside twitter initapi access_token_key:', access_token_key, 'access_token_secret', access_token_secret);
|
|
|
- if (1) {
|
|
|
+ if (access_token_key && access_token_secret) {
|
|
|
this.client = new Twit({
|
|
|
consumer_key: "ewAyFOepelB1Dgczl7LReD3pN",
|
|
|
consumer_secret: "xblu59EZCTrNnW5waDvPjkpaiothQBjDCaJlLaxuezfIdol9Ot",
|
|
|
- access_token: "1205934370546241541-Ma5zbQIMPTVnbRIYTCaUGgpQnqwApu",
|
|
|
- access_token_secret: "mnCbVPV0IuQ8UeRCzZSfM6qnn29m41tkAjXVHTBpySP5i",
|
|
|
+ access_token: access_token_key,
|
|
|
+ access_token_secret: access_token_secret,
|
|
|
timeout_ms: 60 * 1000 // optional HTTP request timeout to apply to all requests.
|
|
|
});
|
|
|
- console.log('new twit client created successfully');
|
|
|
+ await this.openpgp.clearStoredKeys();
|
|
|
} else {
|
|
|
console.error(
|
|
|
"Access Token Key and Secret not set. Creating Twit-client not possible."
|
|
@@ -41,7 +40,6 @@ export class TwitterApiProvider {
|
|
|
* @param maxId tweet id
|
|
|
*/
|
|
|
public async fetchHomeFeed(maxId ? ) {
|
|
|
- console.log('fetchine home feed', this.client);
|
|
|
const res = await this.client.get("statuses/home_timeline", {
|
|
|
count: 20,
|
|
|
include_entities: true,
|
|
@@ -191,6 +189,7 @@ export class TwitterApiProvider {
|
|
|
|
|
|
cursor = res.data["next_cursor"];
|
|
|
friends = friends.concat(res.data["users"]);
|
|
|
+ console.log("friends are:",friends);
|
|
|
}
|
|
|
|
|
|
return friends;
|