小编dsh*_*hap的帖子

要求使用JS SDK扩展权限,而不必使用FB.login()

我正在使用画布应用程序,我想用JS SDK完成以下操作:

  • 检查用户是否已授予特定的扩展权限

    • 如果是这样,调用一些函数startServerProcess()

    • 如果没有,则显示auth对话框以获取权限,并在用户未提供足够访问权限时提醒用户.

我想在客户端完全处理这个问题,除非用户提供正确的权限,否则永远不会调用startServerProcess(),因为它执行的服务器脚本依赖于这些权限.

搜索后,我发现这个解决方案,但它只是使用的FB.login(),我不想打电话每一次,因为如果用户已经通过身份验证,一个恼人的身份验证对话框打开,然后后立即自动关闭.

我最初的解决方法是调用FB.getLoginStatus(),然后做一个图形API调用来/我/权限如果可能的话,只调用的FB.login()如果我真的必须出示一个auth对话框.

这是我现在的代码:

$('#my_ui_button').click(function() {
    require_perms(function(is_authenticated) {
        if(!is_authenticated) {
            startServerProcess();
        } else {
            alert('Sorry, we cannot start the server process until you grant permission');
        }
    });
});


function require_perms(callback) {
    // check if the user is logged in + connected to the app
    FB.getLoginStatus(function(response) {

        // if the user is logged in, continue to check permissions
        if(response.authResponse) {
            FB.api('/me/permissions', function(perms_response) {

                // if photo access already exists, we're good to go
                if(perms_response['data'][0]['user_photos'] …
Run Code Online (Sandbox Code Playgroud)

javascript facebook facebook-graph-api facebook-javascript-sdk facebook-authentication

15
推荐指数
1
解决办法
9436
查看次数

使用resample来对齐pandas中的多个时间序列

这是设置代码:

import pandas
from datetime import datetime

a_values = [1728, 1635, 1733]
a_index = [datetime(2011, 10, 31), datetime(2012, 1, 31), datetime(2012, 4, 30)]
a = pandas.Series(data=a_values, index=a_index)

aa_values = [6419, 5989, 6006]
aa_index = [datetime(2011, 9, 30), datetime(2011, 12, 31), datetime(2012, 3, 31)]
aa = pandas.Series(data=aa_values, index=aa_index)

apol_values = [1100, 1179, 969]
apol_index = [datetime(2011, 8, 31), datetime(2011, 11, 30), datetime(2012, 2, 29)]
apol = pandas.Series(data=apol_values, index=apol_index)
Run Code Online (Sandbox Code Playgroud)

以下是表中数据的样子(未显示APOL的第3个值):

在此输入图像描述

目标是将数据与日历季度标记对齐,以便可以比较3个数据集.只是浏览下面的日期,2012年3月,2011年12月和2011年9月似乎是合理的对齐标记.

这是fill_method ='ffill'的输出:

In [6]: a.resample('Q', fill_method='ffill')
Out[6]: 
2011-12-31    1728
2012-03-31    1635 …
Run Code Online (Sandbox Code Playgroud)

python time-series resampling pandas

4
推荐指数
1
解决办法
4824
查看次数