forked from demoive/graph-api-reporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.gs
67 lines (57 loc) · 1.81 KB
/
menu.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
function menu_init() {
var ui = SpreadsheetApp.getUi();
// var menuInstantArticles = ui.createMenu('Instant Articles')
// .addItem('Single Article Insights', 'menu_iaInsightsArticle')
// .addItem('Aggreggate Insights', 'menu_iaInsightsAggregate');
//ui.createMenu('Facebook Reports')
ui.createAddonMenu()
// .addSubMenu(menuInstantArticles)
.addItem('Instant Article Insights', 'menu_instantArticles')
.addItem('Export Comments', 'menu_exportComments')
.addSeparator()
.addItem('Facebook Login', 'showDialogForFbLoginWithNextAction')
.addItem('Debug Facebook Login', 'menu_debugFbLogin')
.addToUi();
}
function menu_instantArticles() {
//FbLoginInterceptGuard('showSidebarForInstantArticles');
/**/
//FbSdkLogout();
if (FbSdkIsLoggedIn()) {
showSidebarForInstantArticles();
} else {
showDialogForFbLoginWithNextAction('showSidebarForInstantArticles');
}
/**/
}
function menu_debugFbLogin() {
if (FbSdkIsLoggedIn()) {
showDialogForFbLoginDebug();
} else {
showDialogForFbLoginWithNextAction('showDialogForFbLoginDebug');
}
}
/** /
function FbLoginInterceptGuard(functionName) {
//FbSdkLogout();
if (FbSdkIsLoggedIn()) {
window[functionName]();
} else {
showDialogForFbLoginWithNextAction(functionName);
}
}
/**/
function showDialogForFbLoginDebug() {
var ui = SpreadsheetApp.getUi();
var resp = FB.api('/debug_token?input_token='+FB.oauth.getAccessToken());
resp.data.user = FB.api('/'+resp.data.user_id+'?fields=name,picture');
resp.data.access_token = FB.oauth.getAccessToken();
var template = HtmlService.createTemplateFromFile('dialog-fb-login-debug-t');
template.debugInfo = resp.data;
var html = HtmlService
.createHtmlOutput(template.evaluate())
.setWidth(500)
.setHeight(250)
;
ui.showModalDialog(html, 'Facebook Login Debug Info');
}