|
@@ -15,16 +15,20 @@ 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");
|
|
|
- if (access_token_key && access_token_secret) {
|
|
|
+ console.log('inside twitter initapi access_token_key:', access_token_key, 'access_token_secret', access_token_secret);
|
|
|
+ // if (access_token_key && access_token_secret) {
|
|
|
+ if (1) {
|
|
|
this.client = new Twit({
|
|
|
- consumer_key: "UxZkbKotkr8Uc6seupnaZ1kDE",
|
|
|
- consumer_secret: "fEAas8iugR60FOEXsFG0iajq6oyfIIXRBVMlTgWxBd1stWIKHq",
|
|
|
- access_token: access_token_key,
|
|
|
- access_token_secret: access_token_secret,
|
|
|
+ consumer_key: "ewAyFOepelB1Dgczl7LReD3pN",
|
|
|
+ consumer_secret: "xblu59EZCTrNnW5waDvPjkpaiothQBjDCaJlLaxuezfIdol9Ot",
|
|
|
+ access_token: "1205934370546241541-Ma5zbQIMPTVnbRIYTCaUGgpQnqwApu",
|
|
|
+ access_token_secret: "mnCbVPV0IuQ8UeRCzZSfM6qnn29m41tkAjXVHTBpySP5i",
|
|
|
timeout_ms: 60 * 1000 // optional HTTP request timeout to apply to all requests.
|
|
|
});
|
|
|
+ console.log('new twit client created successfully');
|
|
|
} else {
|
|
|
console.error(
|
|
|
"Access Token Key and Secret not set. Creating Twit-client not possible."
|
|
@@ -37,13 +41,15 @@ export class TwitterApiProvider {
|
|
|
* fetch home feed in batches of 20 tweets starting at maxId
|
|
|
* @param maxId tweet id
|
|
|
*/
|
|
|
- public async fetchHomeFeed(maxId?) {
|
|
|
+ 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,
|
|
|
tweet_mode: "extended",
|
|
|
max_id: maxId
|
|
|
- });
|
|
|
+ })
|
|
|
+ console.log('res is:', res);
|
|
|
return res.data;
|
|
|
}
|
|
|
|
|
@@ -71,7 +77,7 @@ export class TwitterApiProvider {
|
|
|
* @param userId user id
|
|
|
* @param maxId max tweet id
|
|
|
*/
|
|
|
- public async fetchUserTimeline(userId, maxId?) {
|
|
|
+ public async fetchUserTimeline(userId, maxId ? ) {
|
|
|
try {
|
|
|
const res = await this.client.get("statuses/user_timeline", {
|
|
|
user_id: userId,
|
|
@@ -141,7 +147,7 @@ export class TwitterApiProvider {
|
|
|
* @param retweet tweet object to retweet
|
|
|
* @param replyToStatusId tweet id to reply to
|
|
|
*/
|
|
|
- public async tweet(status, retweet?, replyToStatusId?) {
|
|
|
+ public async tweet(status, retweet ? , replyToStatusId ? ) {
|
|
|
if (status.length === 0 && retweet) {
|
|
|
// Simple retweet
|
|
|
return await this.client.post("statuses/retweet", {
|
|
@@ -225,7 +231,7 @@ export class TwitterApiProvider {
|
|
|
* @param keyword keyword
|
|
|
* @param maxId max tweet id
|
|
|
*/
|
|
|
- public async searchRecentTweets(keyword: string, maxId?: string) {
|
|
|
+ public async searchRecentTweets(keyword: string, maxId ? : string) {
|
|
|
const res = await this.client.get("search/tweets", {
|
|
|
q: keyword,
|
|
|
result_type: "recent",
|
|
@@ -243,7 +249,7 @@ export class TwitterApiProvider {
|
|
|
* @param keyword keyword
|
|
|
* @param maxId max tweet id
|
|
|
*/
|
|
|
- public async searchPopularTweets(keyword: string, maxId?: string) {
|
|
|
+ public async searchPopularTweets(keyword: string, maxId ? : string) {
|
|
|
const res = await this.client.get("search/tweets", {
|
|
|
q: keyword,
|
|
|
result_type: "popular",
|
|
@@ -261,7 +267,7 @@ export class TwitterApiProvider {
|
|
|
* @param keyword keyword
|
|
|
* @param page page number
|
|
|
*/
|
|
|
- public async searchUsers(keyword: string, page?: number) {
|
|
|
+ public async searchUsers(keyword: string, page ? : number) {
|
|
|
const res = await this.client.get("users/search", {
|
|
|
q: keyword,
|
|
|
count: 10,
|