This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function statusChangeCallback(response) { | |
| if (response.status === 'connected') { | |
| console.log('connected') | |
| fetchUser().then(function(resp) { | |
| var template = '<div><h2>Hi ' + resp.name + ', nice to see you again.</h2></div>'; | |
| var templateObj = $compile(template)(scope); | |
| element.html(templateObj); | |
| }); | |
| } else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function fetchUser() { | |
| var deferred = $q.defer(); | |
| FB.api('/me', function(response) { | |
| deferred.resolve(response) | |
| }); | |
| return deferred.promise; | |
| }; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function login() { | |
| FB.login(function(response){ | |
| console.log(response); | |
| }); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function login() { | |
| FB.login(function(response){ | |
| console.log(response); | |
| },{scope: "email,publish_stream,user_checkins"}); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scope.login = function() { | |
| login().then(validateAuth); | |
| }; | |
| function login() { | |
| var deferred = $q.defer(); | |
| FB.login(function(response){ | |
| deferred.resolve(response) | |
| },{scope: "email,publish_stream,user_checkins"}); | |
| return deferred.promise; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function userCanceled() { | |
| var template = '<div><p>Looks like you canceled the request</p><div id=\'sign_in\' ng-click=\'login()\'>Sign In</div></div>'; | |
| var templateObj = $compile(template)(scope); | |
| element.html(templateObj); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| var app = angular.module('ctLoginsApp.tony.services', ['ngResource']); | |
| app.factory('CT', ['$routeParams', '$q', '$rootScope', '$location', | |
| function() { | |
| var login = function() { | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (response.status === 'connected') { | |
| fetchUser().then(function(resp) { | |
| var msg = | |
| '<h2>Hi ' + resp.name + ', nice to see you again.</h2>' + | |
| '<a href=\'\' ng-click=\'ctLogin()\' class=\'button\'>Login</a>'; | |
| compileTemplate(msg); | |
| }); | |
| } else { ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var doCtLogin = function(params) { | |
| CT.login(params).then(function() { | |
| console.log('You logged in'); | |
| checkinForm(params); | |
| }, function(err) { | |
| console.log(err); | |
| }); | |
| }; | |
| function checkinForm(params) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scope.doCheckin = function() { | |
| var options = { | |
| pageId: attrs.fbPageId, | |
| accessToken: authResponse.accessToken, | |
| message: scope.message | |
| }; | |
| CT.checkin(options).then(function(msg) { | |
| console.log(msg) | |
| // do stuff | |
| }, function(err) { |