I was using this tutorial to learn how to access social network:
http://www.emforge.net/web/akakunin/...-spring-social
Both Twitter and LinkedIn work link charm, thanks, but when I tried facebook, I was stuck and don't know how to solve.
In Status.jsp, It is said to use this code:
<form id="fb_signin" action="<c:url value="/connect/facebook" />" method="post">
<div class="formInfo">
</div>
<div id="fb-root"></div>
<p><fb:login-button perms="email,publish_stream,offline_access" onlogin="$('#fb_signin').submit();" v="2" length="long">Connect to Facebook</fb:login-button></p>
</form>
But Where is <fb:login-button> tag? I can not find it. So I used this instead obtained from facebook:
<script src="http://connect.facebook.net/en_US/all.js#appId=b227323312f4fcb29337f87891811a0e& xfbml=1"></script>
<fb:login-button perms="email,publish_stream,offline_access" onlogin="$('#fb_signin').submit();" v="2" length="long"></fb:login-button>
I don't know if this is right or not.
After I click the fb button, a popup come up, asking for authorization. AFter Allow, the popup closed, and the original form is submit.
I the controller,
@RequestMapping(value="/connect/facebook", method=RequestMethod.POST)
public String connectAccountToFacebook(@FacebookAccessToken String accessToken,
@FacebookUserId String facebookUserId) {
System.out.println("come back from fb2 " + facebookUserId +" token is " + accessToken);
if (facebookUserId != null && accessToken != null) {
// store facebook information
String userName = getCurrentUser().getName();
userService.updateFacebookAuthentication(userName, accessToken, facebookUserId);
}
return "redirect:/status";
}
I did not get any facebookuserid or accessToken.
In the applicationContext.xml, I already added this one;
<!-- Initialize Facebook Argument Resolver -->
<bean class="org.springframework.web.servlet.mvc.annotat ion.AnnotationMethodHandlerAdapter">
<property name="customArgumentResolver" ref="facebookWebArgResolver"/>
</bean>
<bean id="facebookWebArgResolver" class="org.springframework.social.facebook.Faceboo kWebArgumentResolver">
<constructor-arg name="apiKey" value="${facebook.appId}"/>
</bean>
Can anyone tell me why the fbId and accessToken has not been retrieved?
Thanks


Reply With Quote
