spring-attic / spring-social-facebook Goto Github PK
View Code? Open in Web Editor NEWFacebook API binding and connect support.
Home Page: http://projects.spring.io/spring-social-facebook
License: Apache License 2.0
Facebook API binding and connect support.
Home Page: http://projects.spring.io/spring-social-facebook
License: Apache License 2.0
Version: 2.0.2.RELEASE
This is how I create a Facebook instance
@Configuration
public class SocialConfiguration {
@Autowired
private Environment env;
@Bean
public Facebook facebook() {
return new FacebookTemplate(env.getProperty("facebook.accessToken"));
}
}
And this is how I use it:
for (Album album : facebook.mediaOperations().getAlbums(env.getProperty("facebook.pageId"), new PagingParameters(null, null, null, null))) {
log.debug("check if album is of type normal: {}", album.getType());
if (Album.Type.NORMAL.equals(album.getType())) {
// ...
}
}
And here's the output:
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
DEBUG d.s.w.c.f.FacebookGalleryCache - check if album is of type normal: null
Are there any plans to release a version of Spring Social Facebook that supports version 2.4 of the Graph API?
There are some fairly big changes/simplifications around how posts are returned and a few other changes as detailed here:
https://developers.facebook.com/blog/post/2015/07/08/graph-api-v2.4/
FacebookAdapter
sets the profile URL to https://www.facebook.com/app_scoped_user_id/{userId}
. This URL does however not work for non-app-scoped IDs, i.e. users that first authenticated with API versions earlier than 2.0.
The fix is to user profile.getLink()
in ProfileAdapter
.
Hi,
when I want to search within Facebook's public feed using FeedTemplate.searchPublicFeed(String, int, int) it works fine, when there is only one keyword within the query. Facebook supports also logical operators like AND (which actually is represented by a space or +), OR (which is represented by a pipe framed by spaces) and quotes.
Using those operators within a query passed through searchPublicFeed(String, int, int) wouldn't return any results. The reason for that is that internally the query is built and encoded. Since the search terms are also encoded, Facebook is unable to interpret them correctly. This is the same issue when using special characters like German Umlaute.
A solution might be to disable encoding for the search terms. But this seems to be a dirty hack, doesn't it?
My code:
AccessGrant accessGrant = new AccessGrant(token);
Connection<Facebook> facebookConnection = facebookConnectionFactory.createConnection(accessGrant);
return facebookConnection.getApi().feedOperations().getFeed(facebookPageId, new PagingParameters(limit, offset, since, until));
Version: cd965d1
Stacktrace:
Created GET request for "https://graph.facebook.com/v2.2/me?fields=id%2Cabout%2Cage_range%2Cbio%2Cbirthday%2Ccontext%2Ccover%2Ccurrency%2Cdevices%2Ceducation%2Cemail%2Cfavorite_athletes%2Cfavorite_teams%2Cfirst_name%2Cgender%2Chometown%2Cinspirational_people%2Cinstalled%2Cis_verified%2Clanguages%2Clast_name%2Clink%2Clocale%2Clocation%2Cmiddle_name%2Cname%2Cname_format%2Cpolitical%2Cquotes%2Crelationship_status%2Creligion%2Csignificant_other%2Ctimezone%2Cthird_party_id%2Cverified%2Cwebsite%2Cwork"
Setting request Accept header to [application/json, application/*+json]
GET request for "https://graph.facebook.com/v2.2/me?fields=id%2Cabout%2Cage_range%2Cbio%2Cbirthday%2Ccontext%2Ccover%2Ccurrency%2Cdevices%2Ceducation%2Cemail%2Cfavorite_athletes%2Cfavorite_teams%2Cfirst_name%2Cgender%2Chometown%2Cinspirational_people%2Cinstalled%2Cis_verified%2Clanguages%2Clast_name%2Clink%2Clocale%2Clocation%2Cmiddle_name%2Cname%2Cname_format%2Cpolitical%2Cquotes%2Crelationship_status%2Creligion%2Csignificant_other%2Ctimezone%2Cthird_party_id%2Cverified%2Cwebsite%2Cwork" resulted in 400 (Bad Request); invoking error handler
{"error":{"message":"(#100) Tried accessing nonexisting field (age_range) on node type (Page)","type":"OAuthException","code":100}}
Error from Facebook: {"error":{"message":"(#100) Tried accessing nonexisting field (age_range) on node type (Page)","type":"OAuthException","code":100}}
Facebook feed parse cron job failed.
(#100) Tried accessing nonexisting field (age_range) on node type (Page)
org.springframework.social.UncategorizedApiException: (#100) Tried accessing nonexisting field (age_range) on node type (Page)
at org.springframework.social.facebook.api.impl.FacebookErrorHandler.handleUncategorizedError(FacebookErrorHandler.java:158)
at org.springframework.social.facebook.api.impl.FacebookErrorHandler.handleError(FacebookErrorHandler.java:68)
at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:615)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:573)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:544)
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:252)
at org.springframework.social.facebook.api.impl.FacebookTemplate.fetchObject(FacebookTemplate.java:212)
at org.springframework.social.facebook.api.impl.FacebookTemplate.fetchObject(FacebookTemplate.java:207)
at org.springframework.social.facebook.api.impl.UserTemplate.getUserProfile(UserTemplate.java:52)
at org.springframework.social.facebook.api.impl.UserTemplate.getUserProfile(UserTemplate.java:48)
at org.springframework.social.facebook.connect.FacebookAdapter.setConnectionValues(FacebookAdapter.java:42)
at org.springframework.social.facebook.connect.FacebookAdapter.setConnectionValues(FacebookAdapter.java:30)
at org.springframework.social.connect.support.AbstractConnection.setValues(AbstractConnection.java:174)
at org.springframework.social.connect.support.AbstractConnection.initKey(AbstractConnection.java:137)
at org.springframework.social.connect.support.OAuth2Connection.<init>(OAuth2Connection.java:75)
at org.springframework.social.connect.support.OAuth2ConnectionFactory.createConnection(OAuth2ConnectionFactory.java:91)
at mn.astvision.ubds.util.facebook.FacebookUtil.getFeed(FacebookUtil.java:40)
at mn.astvision.ubds.util.facebook.FacebookUtil.getFeed(FacebookUtil.java:35)
at mn.astvision.ubds.cron.FacebookFeedParseCronJob.updateTicketFromPosts(FacebookFeedParseCronJob.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:269)
at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:257)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:75)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: org.springframework.web.client.HttpClientErrorException: 400 Bad Request
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91)
at org.springframework.social.facebook.api.impl.FacebookErrorHandler.handleUncategorizedError(FacebookErrorHandler.java:155)
... 27 more
a facebook account does not necesarily has a username. in this case the name could be set as displayname.
For some of our users, fetching and parsing profile pictures and tagged photos, results in a parsing exception:
2015-04-10 13:51:26,085 [c-16] ERR c.s.f.v.w.c.f.FacebookGalleryPanel$FacebookPhotoModel Could not load images from facebook.
org.springframework.social.UncategorizedApiException: Error deserializing data from Facebook: Can not construct instance of org.springframework.social.facebook.api.Photo$TimeGranularity from String value 'day': value not one of declared Enum instance names: [YEAR, MONTH, DAY, HOUR, MIN, NONE]
at [Source: java.io.StringReader@5a3774f4; line: 1, column: 26069] (through reference chain: java.util.ArrayList[6]->org.springframework.social.facebook.api.Photo["backdated_time_granularity"])
It seems that the field backdated_time_granularity
sometimes contains lower case values such as day
.
GET request for "https://graph.facebook.com/v2.2/me?fields=id%2Cabout%2Cage_range%2Cbio%2Cbirthday%2Ccontext%2Ccover%2Ccurrency%2Cdevices%2Ceducation%2Cemail%2Cfavorite_athletes%2Cfavorite_teams%2Cfirst_name%2Cgender%2Chometown%2Cinspirational_people%2Cinstalled%2Cis_verified%2Clanguages%2Clast_name%2Clink%2Clocale%2Clocation%2Cmiddle_name%2Cname%2Cname_format%2Cpolitical%2Cquotes%2Crelationship_status%2Creligion%2Csignificant_other%2Ctimezone%2Cthird_party_id%2Cverified%2Cwebsite%2Cwork" resulted in 400 (Bad Request); invoking error handler
{"error":{"message":"(#100) Tried accessing nonexisting field (age_range) on node type (Page)","type":"OAuthException","code":100}}
When getting a profile location ou hometown like:
Facebook facebook = new FacebookTemplate(token)
FacebookProfile fbProfile = facebook.userOperations().userProfile
location = facebook.pageOperations().getPage(fbProfile.location.id).location
fbProfile.location returns only name and id
with the id we can get the page/place by doing
facebook.pageOperations().getPage(fbProfile.location.id).location
This location returned is a city and the has just a name and lat long position, no id, no state, no country.
Like shown at the print screen at the link above:
A StatusPost object from facebook's home feed (and other feeds too) can include a place, much like a CheckinPost.
The StatusPost should likewise make that field available. Should investigate if other fields like tags are also sent.
This brakes deserialization from Mongo.
This brakes deserialization from json.
In my case - I'm able to persist Spring's own FacebookProfile to mongo. But I fail to read it back.
Proposed fix:
with Json:
Exception thrown:
...
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.social.facebook.api.Reference]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.social.facebook.api.Reference.()
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:108)
at org.springframework.data.convert.ReflectionEntityInstantiator.createInstance(ReflectionEntityInstantiator.java:61)
... 54 common frames omitted
Caused by: java.lang.NoSuchMethodException: org.springframework.social.facebook.api.Reference.()
at java.lang.Class.getConstructor0(Class.java:2849)
at java.lang.Class.getDeclaredConstructor(Class.java:2053)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:105)
... 55 common frames omitted
CommentOperations.addComment writes comment as authenticated user, how to write as facebook page admin?
AccessGrant accessGrant = new AccessGrant(token);
Connection<Facebook> facebookConnection = facebookConnectionFactory.createConnection(accessGrant);
facebookConnection.getApi().commentOperations().addComment(postId, comment);
I tried using page token instead of user and it throws following exception:
GET request for "https://graph.facebook.com/v2.2/me?fields=id%2Cabout%2Cage_range%2Cbio%2Cbirthday%2Ccontext%2Ccover%2Ccurrency%2Cdevices%2Ceducation%2Cemail%2Cfavorite_athletes%2Cfavorite_teams%2Cfirst_name%2Cgender%2Chometown%2Cinspirational_people%2Cinstalled%2Cis_verified%2Clanguages%2Clast_name%2Clink%2Clocale%2Clocation%2Cmiddle_name%2Cname%2Cname_format%2Cpolitical%2Cquotes%2Crelationship_status%2Creligion%2Csignificant_other%2Ctimezone%2Cthird_party_id%2Cverified%2Cwebsite%2Cwork" resulted in 400 (Bad Request); invoking error handler
{"error":{"message":"(#100) Tried accessing nonexisting field (age_range) on node type (Page)","type":"OAuthException","code":100}}
Stacktrace
org.springframework.web.client.HttpClientErrorException: 400 Bad Request
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91)
at org.springframework.social.facebook.api.impl.FacebookErrorHandler.handleUncategorizedError(FacebookErrorHandler.java:155)
at org.springframework.social.facebook.api.impl.FacebookErrorHandler.handleError(FacebookErrorHandler.java:68)
at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:615)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:573)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:544)
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:252)
at org.springframework.social.facebook.api.impl.FacebookTemplate.fetchObject(FacebookTemplate.java:212)
at org.springframework.social.facebook.api.impl.FacebookTemplate.fetchObject(FacebookTemplate.java:207)
at org.springframework.social.facebook.api.impl.UserTemplate.getUserProfile(UserTemplate.java:52)
at org.springframework.social.facebook.api.impl.UserTemplate.getUserProfile(UserTemplate.java:48)
at org.springframework.social.facebook.connect.FacebookAdapter.setConnectionValues(FacebookAdapter.java:42)
at org.springframework.social.facebook.connect.FacebookAdapter.setConnectionValues(FacebookAdapter.java:30)
at org.springframework.social.connect.support.AbstractConnection.setValues(AbstractConnection.java:174)
at org.springframework.social.connect.support.AbstractConnection.initKey(AbstractConnection.java:137)
at org.springframework.social.connect.support.OAuth2Connection.<init>(OAuth2Connection.java:75)
at org.springframework.social.connect.support.OAuth2ConnectionFactory.createConnection(OAuth2ConnectionFactory.java:91)
at mn.astvision.ubds.util.facebook.FacebookUtil.comment(FacebookUtil.java:56)
at mn.astvision.ubds.controller.TicketController.createLog(TicketController.java:538)
at mn.astvision.ubds.controller.TicketController$$FastClassBySpringCGLIB$$ad4e37d9.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:64)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
at mn.astvision.ubds.controller.TicketController$$EnhancerBySpringCGLIB$$43fae581.createLog(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:301)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:146)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:150)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:74)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1015)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:652)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1575)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1533)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
We have a problem with fetching photos in some accounts.
Spring Social version: 1.0.2.RELEASE
Facebook profile: https://www.facebook.com/SugarLand.TX
Please see exception:
org.springframework.social.UncategorizedApiException: Error deserializing data
from Facebook: Instantiation of [simple type, class
org.springframework.social.facebook.api.Photo] value failed: Index: 2, Size: 2
(through reference chain:
org.springframework.social.facebook.api.Photo["link"])
at
org.springframework.social.facebook.api.impl.FacebookTemplate.deserializeDataList(FacebookTemplate.java:272)
at
org.springframework.social.facebook.api.impl.FacebookTemplate.fetchConnections(FacebookTemplate.java:186)
at
org.springframework.social.facebook.api.impl.MediaTemplate.getPhotos(MediaTemplate.java:100)
....
at java.lang.Thread.run(Thread.java:662)
Caused by: org.codehaus.jackson.map.JsonMappingException: Instantiation of
[simple type, class org.springframework.social.facebook.api.Photo] value
failed: Index: 2, Size: 2 (through reference chain:
org.springframework.social.facebook.api.Photo["link"])
at
org.codehaus.jackson.map.deser.std.StdValueInstantiator.wrapException(StdValueInstantiator.java:388)
at
org.codehaus.jackson.map.deser.std.StdValueInstantiator.createFromObjectWith(StdValueInstantiator.java:232)
at
org.codehaus.jackson.map.deser.impl.PropertyBasedCreator.build(PropertyBasedCreator.java:118)
at
org.codehaus.jackson.map.deser.BeanDeserializer._deserializeUsingPropertyBased(BeanDeserializer.java:910)
at
org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObjectUsingNonDefault(BeanDeserializer.java:739)
at
org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:683)
at
org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
at
org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:217)
at
org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:194)
at
org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:30)
at
org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:2704)
at
org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:2031)
at
org.springframework.social.facebook.api.impl.FacebookTemplate.deserializeDataList(FacebookTemplate.java:270)
Can't retrieve feeds (feedOperations().getFeed()) with version 2.0.0.M1
at org.springframework.social.facebook.api.impl.FeedTemplate.deserializePost(FeedTemplate.java:299) ~[spring-social-facebook-2.0.0.M1.jar:2.0.0.M1]
at org.springframework.social.facebook.api.impl.FeedTemplate.deserializeList(FeedTemplate.java:275) ~[spring-social-facebook-2.0.0.M1.jar:2.0.0.M1]
at org.springframework.social.facebook.api.impl.FeedTemplate.getFeed(FeedTemplate.java:78) ~[spring-social-facebook-2.0.0.M1.jar:2.0.0.M1]
at org.springframework.social.facebook.api.impl.FeedTemplate.getFeed(FeedTemplate.java:64) ~[spring-social-facebook-2.0.0.M1.jar:2.0.0.M1]
Hi,
First of all i think that the library is awesome.
Then, i wanted to notify that the method EventTemplate.getInvitations() only gets the invitations that a user has responded. So if the user receives the invitation and ignores it, it won't be shown because the used connection URL : https://graph.facebook.com/userId/events/ .
To get the events the user has not replied yet, one should call the /events/not_replied end point. So the workaround is as followed:
List invitations = facebook.fetchConnections(userId,
"events/not_replied", Invitation.class, parameters);
which uses https://graph.facebook.com/userId/events/not_replied/
I wonder if it is worth adding in EventTemplate because the user may need to see all the events at once. So maybe the class could expose the method or include it in getInvitations() one.
Thanks.
Mongo keeps complaining about no default constructor for Reference
. I have created a pull request that solves this problem. I have been waiting for this fix since release 1.x. Will really appreciate if this gets integrated for next release.
34:22:629 DEBUG o.s.w.s.FrameworkServlet.processRequest Message=Could not complete request
org.springframework.data.mapping.model.MappingInstantiationException: Failed to instantiate org.springframework.social.facebook.api.Reference using constructor NO_CONSTRUCTOR with arguments
at org.springframework.data.convert.ReflectionEntityInstantiator.createInstance(ReflectionEntityInstantiator.java:64)
at org.springframework.data.convert.BytecodeGeneratingEntityInstantiator.createInstance(BytecodeGeneratingEntityInstantiator.java:76)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:250)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:231)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.readCollectionOrArray(MappingMongoConverter.java:903)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.readValue(MappingMongoConverter.java:1164)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.access$200(MappingMongoConverter.java:78)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter$MongoDbPropertyValueProvider.getPropertyValue(MappingMongoConverter.java:1115)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.getValueInternal(MappingMongoConverter.java:866)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter$1.doWithPersistentProperty(MappingMongoConverter.java:281)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter$1.doWithPersistentProperty(MappingMongoConverter.java:269)
at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:309)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:269)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:231)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:191)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:187)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:78)
at org.springframework.data.mongodb.core.MongoTemplate$ReadDbObjectCallback.doWith(MongoTemplate.java:2191)
at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1873)
at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1696)
at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1679)
at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:598)
I see facebook support post a "place" param when we making a new photo.
https://developers.facebook.com/docs/reference/api/user/#photos
Could you please add it to the implementation ?
To use facebook graph api v.2.0, some code should be modified.
For example, the class FriendTemplate is not supported 2.0
the variable FULL_PROFILE_FIELDS causes bug. user name is not supported no more. If I correct this, where could I get the original source?
the error is like this WARN : org.springframework.web.client.RestTemplate - GET request for "https://graph.facebook.com/me/friends?fields=id%2Cusername%2Cname%2Cfirst_name%2Clast_name%2Cgender%2Clocale%2Ceducation%2Cwork%2Cemail%2Cthird_party_id%2Clink%2Ctimezone%2Cupdated_time%2Cverified%2Cabout%2Cbio%2Cbirthday%2Clocation%2Chometown%2Cinterested_in%2Creligion%2Cpolitical%2Cquotes%2Crelationship_status%2Csignificant_other%2Cwebsite" resulted in 400 (Bad Request); invoking error handler {"error":{"message":"(#100) Unknown fields: username.","type":"OAuthException","code":100}}
Latest snapshots of Spring Social Facebook have switched to v2.2 of Facebook API.
However, in v2.1 and above Facebook removed support for FQL, while sticking with v2.0 API allows applications to use FQL for one more year. Currently Spring Social Facebook doesn't provide a way to change API version it uses without changing its source code.
So, it would be nice to allow application developers to override Facebook API version used by Spring Social Facebook on their own risk.
FacebookProfile prof=.....
System.out.println(prof.getAgeRange());
Result:
The above output generates UNKNOWN as its value though we set up the birthdate in facebook.
I'm hoping I've fundamentally missed something. I upgraded our project to reference 1.1.0.RELEASE of spring social components and the build failed as a 1.1.0.BUILD-SNAPSHOT could not be found.
Upon inspection, this component's release POM depends on non-released components rendering it unusable, at least in a Maven project.
The spring-social-linkedin:1.0.0.RELEASE is also bad: http://search.maven.org/#artifactdetails%7Corg.springframework.social%7Cspring-social-linkedin%7C1.0.0.RELEASE%7Cjar
Looking at the recent change to remove the FacebookOAuth2Template, the URL for facebook's oauth dialog seems to have the Graph Api version missing.
in v2.0.0.M1, the oauth URL would be
https://www.facebook.com/v2.0/dialog/oauth?client_id=...
in v2.0.0.RC1, it is
https://www.facebook.com/dialog/oauth?client_id=...
In the FacebookServiceProvider.java, there's a URL :
OAuth2Template oAuth2Template = new OAuth2Template(appId, appSecret,
"https://www.facebook.com/dialog/oauth",
GraphApi.GRAPH_API_URL + "oauth/access_token");
Using system properties, proxy hostname and port are available in org.springframework.social.support.ClientHttpRequestFactorySelector
but proxy username and password not used because of which getting error : 407 (Proxy Authentication Required); invoking error handler
I want to query the list of public events from a specific user
Is that possible in spring?
Thank you so much
why spring-social(facebook) don't have feed events implemented?
I can't set pictureUrl using FacebookLink
public class FacebookLink {
private final String link;
private final String name;
private final String caption;
private final String description;
On the documentation page at
http://docs.spring.io/spring-social-facebook/docs/2.0.0.RELEASE/reference/htmlsingle/#retrieving-a-user-s-profile-data the following is wrong:
FacebookProfile profile = facebook.userOperations().getUserProfile();
Should be:
User profile = facebook.userOperations().getUserProfile();
That is "User" instead of "FacebookProfile"
a request for /{user}?fields=context
may return a response as simple as this one (using an existing user ID that didn't authorize the app):
{
"id": "{user}"
}
This response causes a NullPointerException at
JsonNode contextNode = responseNode.get("context").get(context);
can we update the Jackson reference to latest .
Hello,
I'm very impressed with the plugin so far. It seems very complete and I have had excellent luck with it.
I ran into an issue this evening with the getStatuses(userId)
method.
def facebook = new FacebookTemplate(accessToken)
println facebook.feedOperations().getStatuses(userId)
org.quartz.JobExecutionException [See nested exception: java.lang.NullPointerException]
at org.codehaus.groovy.grails.plugins.quartz.GrailsJobFactory$GrailsTaskClassJob.execute(GrailsJobFactory.java:81)
at org.quartz.core.JobRunShell.run(JobRunShell.java:199)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:546)
Caused by: java.lang.NullPointerException
at org.springframework.social.facebook.api.impl.json.PostMixin$LikesCountDeserializer.deserialize(PostMixin.java:130)
at org.springframework.social.facebook.api.impl.json.PostMixin$LikesCountDeserializer.deserialize(PostMixin.java:126)
at org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:252)
at org.codehaus.jackson.map.deser.BeanDeserializer._deserializeUsingPropertyBased(BeanDeserializer.java:620)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:472)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:368)
at org.codehaus.jackson.map.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:77)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeWithType(BeanDeserializer.java:423)
at org.codehaus.jackson.map.deser.StdDeserializerProvider$WrappedDeserializer.deserialize(StdDeserializerProvider.java:460)
at org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:2376)
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1731)
at org.springframework.social.facebook.api.impl.FeedTemplate.deserializePost(FeedTemplate.java:274)
at org.springframework.social.facebook.api.impl.FeedTemplate.deserializeList(FeedTemplate.java:260)
at org.springframework.social.facebook.api.impl.FeedTemplate.getStatuses(FeedTemplate.java:99)
at org.springframework.social.facebook.api.impl.FeedTemplate.getStatuses(FeedTemplate.java:93)
at org.springframework.social.facebook.api.FeedOperations$getStatuses.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
at iforce.FacebookJob.execute(FacebookJob.groovy:42)
at sun.reflect.GeneratedMethodAccessor530.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:186)
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:171)
at org.codehaus.groovy.grails.plugins.quartz.GrailsJobFactory$GrailsTaskClassJob.execute(GrailsJobFactory.java:77)
... 2 more
I found the same issue on this thread as well:
http://forum.springsource.org/showthread.php?114901-NullPointer-to-get-status-from-Facebook
Is there any additional information I should provide to help debug this?
Cheers,
Casey
Using spring-social-facebook-2.0.1.RELEASE.jar
When trying to post as a Page admin I get the following error:
(#100) Tried accessing nonexisting field (accounts) on node type (Page)
My code is:
String accessToken = ... ; // the page access token
String pageId = ...; // the page id
Facebook facebook = new FacebookTemplate(accessToken);
PageOperations pageOperations = facebook.pageOperations();
PagePostData pagePostData = new PagePostData(pageId);
pagePostData.link("http://www.mysite.com/mypage", null, null, null, null);
pageOperations.post(pagePostData);
The stack trace is:
org.springframework.social.UncategorizedApiException: (#100) Tried accessing nonexisting field (accounts) on node type (Page)
at org.springframework.social.facebook.api.impl.FacebookErrorHandler.handleFacebookError(FacebookErrorHandler.java:91) ~[FacebookErrorHandler.class:2.0.1.RELEASE]
at org.springframework.social.facebook.api.impl.FacebookErrorHandler.handleError(FacebookErrorHandler.java:59) ~[FacebookErrorHandler.class:2.0.1.RELEASE]
at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:614) ~[RestTemplate.class:4.1.6.RELEASE]
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:570) ~[RestTemplate.class:4.1.6.RELEASE]
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:545) ~[RestTemplate.class:4.1.6.RELEASE]
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:253) ~[RestTemplate.class:4.1.6.RELEASE]
at org.springframework.social.facebook.api.impl.FacebookTemplate.fetchConnections(FacebookTemplate.java:229) ~[FacebookTemplate.class:2.0.1.RELEASE]
at org.springframework.social.facebook.api.impl.FacebookTemplate.fetchConnections(FacebookTemplate.java:223) ~[FacebookTemplate.class:2.0.1.RELEASE]
at org.springframework.social.facebook.api.impl.PageTemplate.getAccounts(PageTemplate.java:61) ~[PageTemplate.class:2.0.1.RELEASE]
at org.springframework.social.facebook.api.impl.PageTemplate.getAccount(PageTemplate.java:125) ~[PageTemplate.class:2.0.1.RELEASE]
at org.springframework.social.facebook.api.impl.PageTemplate.getAccessToken(PageTemplate.java:115) ~[PageTemplate.class:2.0.1.RELEASE]
at org.springframework.social.facebook.api.impl.PageTemplate.post(PageTemplate.java:77) ~[PageTemplate.class:2.0.1.RELEASE]
The log:
o.a.h.impl.execchain.MainClientExec - : Executing request GET /v2.3/me/accounts HTTP/1.1
o.a.h.impl.execchain.MainClientExec - : Proxy auth state: UNCHALLENGED
org.apache.http.headers - : http-outgoing-0 >> GET /v2.3/me/accounts HTTP/1.1
org.apache.http.headers - : http-outgoing-0 >> Accept: application/json, application/*+json
org.apache.http.headers - : http-outgoing-0 >> Authorization: OAuth CAAMLZBlqp0eEBAAmu1eezUeIzQUcTTZCvotVUjZBel6uvBNYscEk8MCtFTnmnPpvGEvtygl1QDclJxK6Y5yaIbJCSatLwONYwFDmyg4cklUTCNl8I6MnMn3zDtbhGXBJSF2oOKj9z1VOogOOzQwZCdcf5PGD0bh9ZAHxeYbYrGzhcZB93jZB32RqwuKEfKcWz8ZD
org.apache.http.headers - : http-outgoing-0 >> Host: graph.facebook.com
org.apache.http.headers - : http-outgoing-0 >> Connection: Keep-Alive
org.apache.http.headers - : http-outgoing-0 >> User-Agent: Apache-HttpClient/4.5 (Java/1.7.0_67)
org.apache.http.headers - : http-outgoing-0 >> Accept-Encoding: gzip,deflate
org.apache.http.wire - : http-outgoing-0 >> "GET /v2.3/me/accounts HTTP/1.1[\r][\n]"
org.apache.http.wire - : http-outgoing-0 >> "Accept: application/json, application/*+json[\r][\n]"
org.apache.http.wire - : http-outgoing-0 >> "Authorization: OAuth CAAMLZBlqp0eEBAAmu1eezUeIzQUcTTZCvotVUjZBel6uvBNYscEk8MCtFTnmnPpvGEvtygl1QDclJxK6Y5yaIbJCSatLwONYwFDmyg4cklUTCNl8I6MnMn3zDtbhGXBJSF2oOKj9z1VOogOOzQwZCdcf5PGD0bh9ZAHxeYbYrGzhcZB93jZB32RqwuKEfKcWz8ZD[\r][\n]"
org.apache.http.wire - : http-outgoing-0 >> "Host: graph.facebook.com[\r][\n]"
org.apache.http.wire - : http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
org.apache.http.wire - : http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.5 (Java/1.7.0_67)[\r][\n]"
org.apache.http.wire - : http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
org.apache.http.wire - : http-outgoing-0 >> "[\r][\n]"
org.apache.http.wire - : http-outgoing-0 << "HTTP/1.1 400 Bad Request[\r][\n]"
org.apache.http.wire - : http-outgoing-0 << "WWW-Authenticate: OAuth "Facebook Platform" "invalid_request" "(#100) Tried accessing nonexisting field (accounts) on node type (Page)"[\r][\n]"
My take:
the library is trying to get the account details using a page token, which is not a permitted operation.
I guess it should skip this step, which is needed when posting as the user (with a user access token), if the access token is a PAGE access token.
When trying to retrieve a single event through Facebook::eventOperations::getEvent(string)
the following error occurs:
I am using Spring Social 2.0.0.RC1.
I have been getting the following JsonMappingException using both the RC1 download and the latest source via GitHub:
org.codehaus.jackson.map.JsonMappingException: Could not resolve type id 'swf' into a subtype of [simple type, class org.springframework.social.facebook.api.Post] at [Source: N/A; line: -1, column: -1]
Using the latest source, this is wrapped into UncategorizedApiException in the deserializeDataList method of the FacebookTemplate class. This happens while getting a Facebook feed, which uses the fetchConnections method of the same FacebookTemplate class. Instead of an expected type value of link, photo, video, etc., it looks like Facebook returns a type of 'swf', which Jackson cannot handle since it does not map to any of the subtypes of the Post class. At least, that's what I think has happened?
If I am correct and since such discrepancies may (and I think frequently will) happen with any social api, shouldn't there be a fallback strategy? In this case, I'm thinking of either a way to ignore (if desired) such exceptions so that at least the rest of the feed can be captured, or a default handler for uncategorized types that may be implemented by developers depending on their needs.
Even though not directly related to the above, in a similar spirit, wouldn't it be nice to provide a convenient way to extend the functionality of the templates and operations interfaces. First of all, these social apis change unexpectedly and it would be nice to keep up-to-date without waiting for the next version of spring social to catch up. If we could extend existing classes with a few added or modified methods until a new version, this would help immensely with regard to maintenance. Currently, as far as I can see, there are too many private properties preventing such extensions. Even when the social api does not change, it would be useful to extend these classes for application-specific extensions. For example, currently you can only fetch an image as a byte array. However, it may be preferable to fetch the url for each image and let the browser handle downloading each image. To add such functionality, one would need to extend UserOperations, GraphApi, UserTemplate, FacebookTemplate with a few simple method definitions.
Anyhow, Spring Social is great, thanks for the hard work, and thanks for taking the time to look into the above issue.
In 2.0.0.M1 Spring Social Facebook, the distance method parameter is primitive and non-nullable - therefore the 'distance' parameter must be set when the Facebook API /search contract declares distance as an optional parameter when searching for places.
Re-implementing the search(query, lat, lon, distance) as the following would allow the distance parameter to be optional.
public PagedList<Page> search(String query, double latitude, double longitude, Long distance) {
requireAuthorization();
MultiValueMap<String, String> queryMap = new LinkedMultiValueMap<String, String>();
queryMap.add("q", query);
queryMap.add("type", "place");
queryMap.add("center", latitude + "," + longitude);
if(distance !=null){
queryMap.add("distance", distance.toString());
}
return graphApi.fetchConnections("search", null, Page.class, queryMap);
}
Additionally, the PageTemplate implementation exposes a generic Page search(String query)
method, however the PageOperations interface does not surface this method - any particular reason?
Last couple of weeks we're facing lot of following errors when users try to sign up with Facebook to our app
org.springframework.social.connect.web.ProviderSignInController oauth2Callback: Exception while completing OAuth 2 connection:
java.lang.IllegalStateException: The OAuth2 'state' parameter doesn't match.
thanks to nasty Facebook bug: Callback URL being called multiple times
Because we all know how responsive is FB with fixing the issues I wonder if could be some workaround done here.
This error can be easily replicated
signin.jsp
file put `<% Thread.sleep(5000) %>mvn tomcat:run-war
I've tried couple of workarounds but none of them worked
state already used
exception.Hi,
template.feedOperations().getLinks() causes JsonMappingException on Post$Privacy field.
** UPDATE
Same goes for getPosts() & getFeed()
Thanks,
Yoni
The Post class object returned by FeedOperations methods (like getFeed() ) doesn't contain such fields as:
Please see here https://developers.facebook.com/docs/reference/api/post/
But if I make a Facebook API call using this URL
https://developers.facebook.com/tools/explorer?method=GET&path=habuma%2Ffeed
I will get JSON (Posts) with all fields listed above without any additional API calls.
Please do not ignore fields mentioned above, parse them from JSON and add to Post (org.springframework.social.facebook.api.Post)
There is no way to get such Facebook post fields, even using additional Spring Social Facebook method calls: privacy, place, story, shares, status_type
Also I have noticed that Post.getLikeCount() always returns 0
However, comments and likes can be retrieved using additional invocation of LikeOperations and CommentOperations methods, but it is still not acceptable because we should do 2 additional requests on each Post that hit rate limit very hard. Facebook Rate limit is unofficial but exists, please see here
http://stackoverflow.com/questions/8805316/facebook-graph-api-rate-limit-and-batch-requests
spring-social-facebook-web/src/main/resources/META-INF/facebook.tld does exist in master, but missed in 1.0.3.RELEASE jar.
Facebook's JavaScript API can't be used without it.
In MongoDB, persisting Reference object works fine but retrieving fails as there is no default constructor. Something like this solves the exception below. Preferred, if this is fixed in 1.1.1 and 2.0.0
@SuppressWarnings("unused")
private Reference() {
this(null, null);
}
2014-07-08 22:50:44,631 [http-bio-8080-exec-10] ERROR org.springframework.social.connect.web.ProviderSignInController- Exception while completing OAuth 2 connection:
org.springframework.data.mapping.model.MappingInstantiationException: Failed to instantiate org.springframework.social.facebook.api.Reference using constructor NO_CONSTRUCTOR with arguments
at org.springframework.data.convert.ReflectionEntityInstantiator.createInstance(ReflectionEntityInstantiator.java:64)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:243)
I am seeing the following bugs in my usage of V2.0.0.0M1:
https://jira.spring.io/browse/SOCIALFB-163
https://jira.spring.io/browse/SOCIALFB-153
Building from source is currently not possible as all of our dependencies have be maven repo backed. Given that facebook will be removing v1.0 of their API in 4 weeks when can we expect a stable release of spring-social-facebook for v2.0 of the api?
If this project is no longer supported that would also be useful to know as we will use a different library.
Game time folks, FB is pushing all consumers to v2, and v1 is going offline Apr 30, 2015. We've been using 1.1.1.RELEASE, but now we're getting emails from FB that our app needs to be upgraded https://developers.facebook.com/apps/upgrade/?ref=devsite_banner
"Prevent Broken Experiences in Your Mobile Apps - We Recommend Upgrading to v2.0+ Before December 25th.
Did you know it usually takes 80-140 days for 90% of people to upgrade to the latest version of your app?"
I presume 2.0.0.M1 is the current milestone. What is critical to in order to prep 2.0.0 for production?
We use social api for auth and posting. I can make myself available to test any further builds on a high-volume site.
Please update the changelog for v2.0.1: it is stuck at 1.1.0.RC1
Hello
I know that Facebook support several ways of Paginating see http://developers.facebook.com/docs/reference/api/pagination/
I tried to find the ways how to do it. I saw that there is unofficial brunch http://developers.facebook.com/docs/reference/api/pagination/ but I looks like it is enough old. Moreover I saw that there is official branch v1.1.0M2 which supports one more way of pagination. However it does not work for me (NPE). I can provide my stacktrace if you develop this branch.
I really need something more than offset/limit. Please advice.
RealTimeUpdateController missing init method or @Inject annotation on Constructor
Is there a reason that this class isn't public?
The methods contained are quite useful if you're accessing Facebook API end points which aren't catered for by spring-social-facebook already. At the moment, I've had to duplicate the methods in my application which seems wasteful.
The actual problem is that WorkEntry.Project
fails to parse (see stacktrace below).
The returned data looks like this:
"work": [
{
"employer": {
"id": "{id}",
"name": "{name}"
},
"projects": [
{
"id": "{id}",
"name": "{name}"
},
{
"id": "{id}",
"name": "{name}"
}
],
"start_date": "{date}"
}
]
The real cause however is that FacebookAdapter.setConnectionValues()
fetches far too much data.
Stacktrace:
org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Unrecognized field "id" (class org.springframework.social.facebook.api.WorkEntry$Project), not marked as ignorable (4 known properties: "end_date", "start_date", "description", "with"])
at [Source: java.io.ByteArrayInputStream@3f9d6ec6; line: 1, column: 8712] (through reference chain: org.springframework.social.facebook.api.User["work"]->org.springframework.social.facebook.api.WorkEntry["projects"]->org.springframework.social.facebook.api.Project["id"]); nested exception is com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "id" (class org.springframework.social.facebook.api.WorkEntry$Project), not marked as ignorable (4 known properties: "end_date", "start_date", "description", "with"])
at [Source: java.io.ByteArrayInputStream@3f9d6ec6; line: 1, column: 8712] (through reference chain: org.springframework.social.facebook.api.User["work"]->org.springframework.social.facebook.api.WorkEntry["projects"]->org.springframework.social.facebook.api.Project["id"])
at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.readJavaType(MappingJackson2HttpMessageConverter.java:228) ~[spring-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.read(MappingJackson2HttpMessageConverter.java:220) ~[spring-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:95) ~[spring-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:550) ~[spring-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:518) ~[spring-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:256) ~[spring-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
at org.springframework.social.facebook.api.impl.FacebookTemplate.fetchObject(FacebookTemplate.java:214) ~[spring-social-facebook-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.social.facebook.api.impl.FacebookTemplate.fetchObject(FacebookTemplate.java:209) ~[spring-social-facebook-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.social.facebook.api.impl.UserTemplate.getUserProfile(UserTemplate.java:53) ~[spring-social-facebook-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.social.facebook.api.impl.UserTemplate.getUserProfile(UserTemplate.java:49) ~[spring-social-facebook-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.social.facebook.connect.FacebookAdapter.setConnectionValues(FacebookAdapter.java:43) ~[spring-social-facebook-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.social.facebook.connect.FacebookAdapter.setConnectionValues(FacebookAdapter.java:31) ~[spring-social-facebook-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.social.connect.support.AbstractConnection.setValues(AbstractConnection.java:174) ~[spring-social-core-1.1.0.RELEASE.jar:1.1.0.RELEASE]
at org.springframework.social.connect.support.AbstractConnection.initKey(AbstractConnection.java:137) ~[spring-social-core-1.1.0.RELEASE.jar:1.1.0.RELEASE]
at org.springframework.social.connect.support.OAuth2Connection.<init>(OAuth2Connection.java:75) ~[spring-social-core-1.1.0.RELEASE.jar:1.1.0.RELEASE]
at org.springframework.social.connect.support.OAuth2ConnectionFactory.createConnection(OAuth2ConnectionFactory.java:91) ~[spring-social-core-1.1.0.RELEASE.jar:1.1.0.RELEASE]
at org.springframework.social.security.provider.OAuth2AuthenticationService.getAuthToken(OAuth2AuthenticationService.java:99) ~[spring-social-security-1.1.0.RELEASE.jar:1.1.0.RELEASE]
...
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "id" (class org.springframework.social.facebook.api.WorkEntry$Project), not marked as ignorable (4 known properties: "end_date", "start_date", "description", "with"])
at [Source: java.io.ByteArrayInputStream@3f9d6ec6; line: 1, column: 8712] (through reference chain: org.springframework.social.facebook.api.User["work"]->org.springframework.social.facebook.api.WorkEntry["projects"]->org.springframework.social.facebook.api.Project["id"])
at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:51) ~[jackson-databind-2.4.0.jar:2.4.0]
at com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:731) ~[jackson-databind-2.4.0.jar:2.4.0]
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:915) ~[jackson-databind-2.4.0.jar:2.4.0]
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1292) ~[jackson-databind-2.4.0.jar:2.4.0]
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1270) ~[jackson-databind-2.4.0.jar:2.4.0]
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:247) ~[jackson-databind-2.4.0.jar:2.4.0]
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:118) ~[jackson-databind-2.4.0.jar:2.4.0]
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:232) ~[jackson-databind-2.4.0.jar:2.4.0]
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:206) ~[jackson-databind-2.4.0.jar:2.4.0]
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:25) ~[jackson-databind-2.4.0.jar:2.4.0]
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:538) ~[jackson-databind-2.4.0.jar:2.4.0]
at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:106) ~[jackson-databind-2.4.0.jar:2.4.0]
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:242) ~[jackson-databind-2.4.0.jar:2.4.0]
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:118) ~[jackson-databind-2.4.0.jar:2.4.0]
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:232) ~[jackson-databind-2.4.0.jar:2.4.0]
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:206) ~[jackson-databind-2.4.0.jar:2.4.0]
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:25) ~[jackson-databind-2.4.0.jar:2.4.0]
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:538) ~[jackson-databind-2.4.0.jar:2.4.0]
at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:106) ~[jackson-databind-2.4.0.jar:2.4.0]
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:242) ~[jackson-databind-2.4.0.jar:2.4.0]
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:118) ~[jackson-databind-2.4.0.jar:2.4.0]
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3051) ~[jackson-databind-2.4.0.jar:2.4.0]
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2206) ~[jackson-databind-2.4.0.jar:2.4.0]
at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.readJavaType(MappingJackson2HttpMessageConverter.java:225) ~[spring-web-4.0.4.RELEASE.jar:4.0.4.RELEASE]
... 66 common frames omitted
When i try to add spring-social to my project i get this error for social.xml.
Any suggestion for that?
Multiple annotations found at this line:
- schema_reference.4: Failed to read schema document 'http://
www.springframework.org/schema/social/spring-social-facebook.xsd', because 1) could not
find the document; 2) the document could not be read; 3) the root element of the document is
not xsd:schema.
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be
found for element 'facebook:config'.
When using the getTaggableFriends() method (version 2.0.0.RELEASE), the following error is returned by Facebook:
{
"error": {
"message": "Syntax error \"Expected end of string instead of \"(\".\" at character 13: picturefields(is_silhouette,url,width,height)",
"type": "OAuthException",
"code": 2500
}
}
The reason for this, is that the end point requests the following fields, with picturefields being the problem:
"id", "name" ,"picturefields(is_silhouette,url,width,height)", "first_name", "last_name", "middle_name"
The following is the format that Facebook expects for the picture fields:
"id", "name", "picture{is_silhouette,url,width,height}", "first_name", "last_name", "middle_name"
I have found bug in the following method
org.springframework.social.facebook.api.impl.PagedListUtils#getPagedListParameters(JsonNode pagingNode, String pageKey)
The following code
return new PagingParameters(
offsetString != null ? Integer.valueOf(offsetString) : null,
limitString != null ? Integer.valueOf(limitString) : null,
sinceString != null ? Long.valueOf(sinceString) : null,
untilString != null ? Long.valueOf(untilString) : null);
have to be replaced to the following one:
return new PagingParameters(
limitString != null ? Integer.valueOf(limitString) : null,
offsetString != null ? Integer.valueOf(offsetString) : null,
sinceString != null ? Long.valueOf(sinceString) : null,
untilString != null ? Long.valueOf(untilString) : null);
as we have wrong order of limit and offset params.
Hi,
I need to access to Facebook Ads/Insights API. It would be convenient to access it through Spring Social Facebook extension. But currently it is not possible.
On github I found some old implementation that was not merged in (#3). On Spring Social Facebook JIRA I also found old unresolved issue (SOCIALFB-34).
So I want to ask question: how things are going with integration between Spring Social Facebook and Facebook Ads/Marketing API? What are the plans? Why changes were not merged into master branch?
Please notice that I am willing to spend some time on this issue if it is required. I have to implement this feature no matter what. So I can share it on github if you want.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.