使用 Localhost 登录

Twitter Log in with Localhost

所以我试图让我的用户登录到 Twitter,从而将他们的 Twitter 帐户连接到我网站的帐户。我希望它的工作方式是,他们将单击一个按钮,它会弹出(或重定向到)一个他们可以登录的 Twitter 页面。然后我会得到他们的推特用户名(是的,只有用户名)。

我怎样才能做到这一点?我真的很感激一个例子,到目前为止官方 twitter 网站上的教程和指南并没有真正帮助我。

我只使用 php 和 javascript,网站在本地主机上是 运行。我在 Twitter 上创建了一个开发者帐户,但我不确定我的 "Website Url"(它不接受 http://localhost or http://127.0.0.1)和 "Callback Url" 应该是什么。

在此先感谢您,如果这是非常基本或简单的事情,我们深表歉意。

Please note - any callback URL that you use with the POST oauth/request_token endpoint will have to be whitelisted within the Twitter app settings in the app details page of developer portal

From: https://developer.twitter.com/en/docs/basics/authentication/oauth-1-0a/obtaining-user-access-tokens

Twitter 不会列入白名单 localhost - 因此您在测试时需要一个临时域。

假设您要访问“http://localhost:8000”,那么您必须在域中输入“http://www.localhost:8000”。

只需添加“www”,您就可以访问您的本地主机。 这对我有用