gpt4 book ai didi

java - 使用 Webview 和 Httpclient 检查用户是否登录

转载 作者:行者123 更新时间:2023-11-29 02:29:30 25 4
gpt4 key购买 nike

我需要查看用户是否登录到我的 webview 网站,为此我需要运行一个脚本来查看用户的值(如果未登录则为 0)。 url/checklogin.php 是脚本。 webview 工作正常,但我无法从 php 获取值到 android。 httpclient 始终返回 0,即使我使用 webview 登录也是如此。

这是 php 脚本

<?php    
include 'wp-load.php';
global $current_user;
$current_user = wp_get_current_user();
$id=$current_user->ID;
echo $id;
?>

最佳答案

在您的 WebViewClient 中,覆盖 onReceivedErroronPageStartedonPageFinished。您必须拥有 accessTokenauthToken 才能确认用户是否已通过身份验证。您可以根据它执行下一步操作。

mWebView.setWebViewClient(new WebViewClient() {

@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {

}

@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {

}

@Override
public void onPageFinished(WebView view, String url) {

}
});

}

关于java - 使用 Webview 和 Httpclient 检查用户是否登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50389536/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com