点击我网站上的按钮登录另一个网站


Login to another website on click of button on my website

我需要在我的网站上创建一个按钮,所有登录用户都可以访问该按钮。此按钮将使用存储的凭据登录到其他网站。这意味着所有用户都将使用相同的登录凭据登录到其他网站。

我搜索了解决方案。我只能在 php 中找到curl,在 Java 中找到URLConnection。但是我读了多少,似乎curl和urlconnection只能从其他网站读取数据。但是我需要在单击我网站上的按钮后重定向到其他网站。

请告诉我有没有办法做到这一点。

我还尝试了iframe来控制其他网站登录页面,但这不起作用。他们的网站在https上。

您可以使用 Web 浏览器的 Localstorage ,以便检查 localstorage 值

     //logged IN 
    if (!localStorage.userid || localStorage.userid == '') {
       //show you button;
    }else { //hide you button }

但您必须控制其他网站才能检查凭据或记录的状态。

你可以使用

response.sendRedirect("https://otherwebsite.com/login?username=user&pwd=password");

出于安全原因,这通常不是最好的主意。另一种方法是发送带有隐藏字段的表单(通过https,因此数据被加密),并自动提交到 otherwebsite.com。