diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 940dd9e..e28f233 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -20,6 +20,7 @@ import { HttpClientModule } from '@angular/common/http';
import { NewsService } from './services/news.service';
import { MatchService } from './services/match.service';
import { ToastService } from './services/toast.service';
+import { UserService } from './services/user.service';
@NgModule({
declarations: [AppComponent],
@@ -37,6 +38,7 @@ import { ToastService } from './services/toast.service';
AppVersion,
NewsService,
MatchService,
+ UserService,
ToastService,
HTTP,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
diff --git a/src/app/components/facebook-login/facebook-login.component.html b/src/app/components/facebook-login/facebook-login.component.html
index 02114ef..b3d3b08 100644
--- a/src/app/components/facebook-login/facebook-login.component.html
+++ b/src/app/components/facebook-login/facebook-login.component.html
@@ -4,6 +4,8 @@
+
+
diff --git a/src/app/components/facebook-login/facebook-login.component.ts b/src/app/components/facebook-login/facebook-login.component.ts
index 2c4fbc6..62afc0a 100644
--- a/src/app/components/facebook-login/facebook-login.component.ts
+++ b/src/app/components/facebook-login/facebook-login.component.ts
@@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core';
+import { UserService } from '../../services/user.service';
// For capacitor Facebook
import { Platform } from '@ionic/angular';
@@ -26,7 +27,8 @@ export class FacebookLoginComponent implements OnInit {
constructor(
private platform: Platform,
- private http: HttpClient
+ private http: HttpClient,
+ private userService: UserService
) {
}
@@ -81,7 +83,11 @@ export class FacebookLoginComponent implements OnInit {
this.token = result.accessToken;
this.loadUserData();
- localStorage.setItem('FBToken', this.token);
+ localStorage.setItem('FBToken', JSON.stringify(this.token));
+
+
+ this.userService.getUserProfile().then((data) => alert(JSON.stringify(data)), err => alert(JSON.stringify(err)));
+
} else {
// Not logged in.
}
diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts
index 65a01a1..8251ce6 100644
--- a/src/app/home/home.page.ts
+++ b/src/app/home/home.page.ts
@@ -6,6 +6,7 @@ import { ToastService } from '../services/toast.service';
import { DomSanitizer } from '@angular/platform-browser';
import { SocialSharing } from '@ionic-native/social-sharing/ngx';
import { Platform } from '@ionic/angular';
+import { UserService } from '../services/user.service';
@Component({
selector: 'app-home',
@@ -43,6 +44,7 @@ export class HomePage implements OnInit {
private dom: DomSanitizer,
private socialSharing: SocialSharing,
private platform: Platform,
+ private userService: UserService
) { }
transformYourHtml(htmlTextWithStyle) {
diff --git a/src/app/services/user.service.spec.ts b/src/app/services/user.service.spec.ts
new file mode 100644
index 0000000..3f804c9
--- /dev/null
+++ b/src/app/services/user.service.spec.ts
@@ -0,0 +1,16 @@
+import { TestBed } from '@angular/core/testing';
+
+import { UserService } from './user.service';
+
+describe('UserService', () => {
+ let service: UserService;
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({});
+ service = TestBed.inject(UserService);
+ });
+
+ it('should be created', () => {
+ expect(service).toBeTruthy();
+ });
+});
diff --git a/src/app/services/user.service.ts b/src/app/services/user.service.ts
new file mode 100644
index 0000000..c0fc3e0
--- /dev/null
+++ b/src/app/services/user.service.ts
@@ -0,0 +1,41 @@
+import { Injectable } from '@angular/core';
+import { HttpClient, HttpHeaders } from '@angular/common/http';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class UserService {
+ BASE_URL: string = 'https://fan-engagement.techmahindra.com';
+
+// /like-article/:id
+// /bookmark-article/:id
+
+ constructor(
+ private http: HttpClient
+ ) { }
+
+ likePost(postId: string) {
+ const httpOptions = {
+ headers: new HttpHeaders({
+ 'Access-Control-Allow-Origin': '*',
+ 'Content-Type': 'application/json',
+ 'Authorization': 'Bearer ' + JSON.parse(localStorage.getItem('FBToken')).token
+ })
+ };
+
+ return this.http.get(this.BASE_URL + '/like-article/' + postId, httpOptions).toPromise();
+ }
+
+ getUserProfile() {
+ const httpOptions = {
+ headers: new HttpHeaders({
+ 'Access-Control-Allow-Origin': '*',
+ 'Content-Type': 'application/json',
+ 'Authorization': 'Bearer ' + JSON.parse(localStorage.getItem('FBToken')).token
+ })
+ };
+
+ return this.http.get(this.BASE_URL + '/user-details/', httpOptions).toPromise();
+ }
+
+}