我遵循了这个问题如何在java中通过facebook登录验证用户,但很难遵循它。 Web 应用程序依赖于 Ejb 应用程序,因此我无法在 netbeans 上运行它。
您可以使用Twitter4j和Facebook4j api来解决您的问题,非常容易使用Twitter4j登录示例
public static void main(String[] args) throws TwitterException, IOException{
StatusListener listener = new StatusListener(){
public void onStatus(Status status) {
System.out.println(status.getUser().getName() + " : " + status.getText());
}
public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {}
public void onTrackLimitationNotice(int numberOfLimitedStatuses) {}
public void onException(Exception ex) {
ex.printStackTrace();
}
};
TwitterStream twitterStream = new TwitterStreamFactory().getInstance();
twitterStream.addListener(listener);
// sample() method internally creates a thread which manipulates TwitterStream and calls these adequate listener methods continuously.
twitterStream.sample();
}
在这里您可以查看简单的JSP示例如何使用Twitter创建登录
首先,您需要在任何想要执行直接登录的应用程序中创建一个开发者帐户。 然后,从该帐户或平台,您必须创建虚拟项目并获取 api 密钥,在此之前,您需要创建具有身份验证和授权以及会话处理的登录页面,然后您可以将特定的 api 密钥添加到您的配置文件中项目,您将获得功能。