小编Tho*_*ont的帖子

getLoginStatus javascript facebook在页面重新加载时消失

我实现了facebook连接,它工作正常.

登录后,此函数返回我的名字.

FB.getLoginStatus(function (response) {
    if (response && response.status === 'connected') {
         FB.api('/me', function(response) {
            console.log('Good to see you, ' + response.name + '.');
        });
        //console.log('connected');
    } else {
        console.log('not connected with FB');
    }
});  
Run Code Online (Sandbox Code Playgroud)

但是,当我重新加载页面时,我记得这个函数,它返回'与FB无关'.

我加入登录功能来帮助:

    FB.login(function(response) {

    if (response.authResponse){
      //L'utilisateur a autorisé l'application
      //window.location.replace("http://adresse/de/redirection");
    } else {
      //L'utilisateur n'a pas autorisé l'application
    }
  }, {scope: 'public_profile,user_friends,email'});
Run Code Online (Sandbox Code Playgroud)

我在facebook文档中找不到任何解决方案

为了显示问题,我的控制台日志是这样的: 使用我的代码控制台日志

编辑:请附上我的完整代码.我从localhost处理

<!DOCTYPE html>
<html>
<head>
<title>Facebook Login JavaScript Example</title>
<meta charset="UTF-8">

</head>
<body>

<button id="loginBtn">Facebook Login</button>
<div id="response"></div>

</body> …
Run Code Online (Sandbox Code Playgroud)

javascript facebook

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

Stripe 3d 安全订阅失败

我对 Stripe 的测试环境有一个关于 3D 安全流程和订阅的问题。我担心在没有验证或解释问题的情况下将流程推向生产。

\n\n

我根据文档执行了所有 3d 安全和订阅过程。

\n\n

https://stripe.com/docs/sources/third-d-secure/subscriptions

\n\n

当我通过禁用试用期来激活订阅时,我所做的所有尝试都失败了。

\n\n

在此输入图像描述

\n\n

我正在使用需要 3D 安全的测试卡:4000 0000 0000 3063

\n\n

我的代码流程:

\n\n
<!DOCTYPE html>\n<html lang="fr">\n<head>\n    <meta charset="UTF-8">\n    <title>Source test Stripe</title>\n    <script src="https://js.stripe.com/v3/"></script>\n    <style>\n        .StripeElement {\n            background-color: white;\n            height: 40px;\n            padding: 10px 12px;\n            border-radius: 4px;\n            border: 1px solid transparent;\n            box-shadow: 0 1px 3px 0 #e6ebf1;\n            -webkit-transition: box-shadow 150ms ease;\n            transition: box-shadow 150ms ease;\n        }\n\n        .StripeElement--focus {\n            box-shadow: 0 1px 3px 0 #cfd7df;\n        }\n\n        .StripeElement--invalid {\n            border-color: #fa755a;\n        }\n\n        .StripeElement--webkit-autofill …
Run Code Online (Sandbox Code Playgroud)

php stripe-payments

3
推荐指数
1
解决办法
7985
查看次数

WKWebView中的javascript桥不起作用

我尝试使用从Web视图中获取javascript消息WKWebView。但是IOS控制台内部什么也没有出现...

我实现以下代码:

- (void) webView:(WKWebView *)webView didFailLoadWithError:(NSError *)error {
    self.webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.height-20)];
    self.webView.backgroundColor = [UIColor whiteColor];

    self.webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);

    self.webView.scrollView.delegate = self;
    [self.view addSubview:self.webView];

    // Setup WKUserContentController instance for injecting user script

    WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc]
         init];

    WKUserContentController* userController = [[WKUserContentController alloc]init];

    [userController addScriptMessageHandler: self name:@"notification"];
    configuration.userContentController = userController;

    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://example.com/test.php"]]];
}

- (void)userContentController:(WKUserContentController*)userContentController
      didReceiveScriptMessage:(WKScriptMessage*)message {
    NSLog(@"%@", message.body);
}
Run Code Online (Sandbox Code Playgroud)

和HTML / JS:

<div id="test" onclick="test();">test</div>

<script type="text/javascript" src="jquery.js"></script> …
Run Code Online (Sandbox Code Playgroud)

javascript objective-c wkwebview

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

打字稿:通用类型设置后调用函数/方法

对于一个项目,我会把一个函数的实现和这个函数的调用分开。

它是这样的:

function identity<T, R>(arg: T): R {
    return { result: arg };
}

const test = identity<string, { result: string }>;

console.log(test('test'))

Run Code Online (Sandbox Code Playgroud)

我收到此错误:“测试不是函数”

有没有办法像这样执行类型提示?

谢谢

typescript

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