2016-02-24 32 views
0

在基于spring-boot的应用程序中,我将获得使用apiKey和appSecret进行连接的Facebook用户朋友,并使用facebook用户标识来标识用户(无用户访问令牌)。spring-boot我可以使用FacebookAuthenticationService与apiKey和appSecret连接吗?

我知道通过facebook api图我可以使用facebook api endpoint/{user-id}/friends来获取用户朋友列表,并且我可以使用应用程序令牌而不是用户访问令牌。

我tryng来实例化的Facebook这样的:

import org.springframework.social.facebook.api.Facebook; 
import org.springframework.social.facebook.security.FacebookAuthenticationService; 
... 
Facebook facebook = new FacebookAuthenticationService(apiKey, appSecret); 

但是当我包括我的代码,此行中我得到这个编译错误:

类型org.springframework.social.security。 provider.OAuth2AuthenticationService无法解析。它是间接需要的.class文件

内FacebookAuthenticationService.class引用存在的

import org.springframework.social.security.provider.OAuth2AuthenticationService; 
不会在构建路径中存在

进口....我无法找到一个

<groupId>org.springframework.boot</groupId> 
<artifactId>spring-boot-starter-social-security</artifactId> 

像放不是春启动

<groupId>org.springframework.social</groupId> 
<artifactId>spring-social-security</artifactId> 

,但我不能有第二个'因为我会得到一个不同的错误durind的

 Facebook facebook = new FacebookAuthenticationService(apiKey, appSecret); 

实例化的错误是:

类型不匹配:不能转换从FacebookAuthenticationService给Facebook

我不知道是否有人能帮助我...

回答

1

据我了解您的问题,您连接的方式不需要OAuth。 你想让服务器连接到facebook的凭证,你已经拥有了,对吧? 比你必须使用FacebookTemplate连接。 我这样做的一个项目,我只有

<dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-web</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-security</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.social</groupId> 
     <artifactId>spring-social-facebook</artifactId> 
    </dependency> 

另见我的回答对stackoverflow 35535091

+0

是的,谢谢你打开我的心!我必须使用新的FacebookTemplate(appToken); (用appToken代替用户访问令牌) –

相关问题