Announcement Announcement Module
Collapse
No announcement yet.
Twitter SearchOperations problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Twitter SearchOperations problem

    I was using twitter SearchOperations API for getting Trends. It is throwing error in case of DailyTrends and CurrentTrends. WeeklyTrends and LocalTrends are searching data.

    List <Trends> trendsList = twitter.searchOperations().getDailyTrends();
    Error

    Code:
    org.springframework.web.client.ResourceAccessException: I/O error: (was java.lang.NullPointerException) (through reference chain: org.springframework.social.twitter.api.impl.DailyTrendsList["trends"]); nested exception is org.codehaus.jackson.map.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: org.springframework.social.twitter.api.impl.DailyTrendsList["trends"])
    	at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:453)
    	at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:415)
    	at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:213)
    	at org.springframework.social.twitter.api.impl.SearchTemplate.getDailyTrends(SearchTemplate.java:111)
    	at org.springframework.social.twitter.api.impl.SearchTemplate.getDailyTrends(SearchTemplate.java:102)
    	at com.campaign.controller.TwitterController.showTrends(TwitterController.java:88)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
    	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
    	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
    	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1148)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:312)
    	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
    	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:324)
    	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:324)
    	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:101)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:324)
    	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:324)
    	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:324)
    	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:324)
    	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:182)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:324)
    	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:324)
    	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:324)
    	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:174)
    	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
    	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1139)
    	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:378)
    	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)
    	at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
    	at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.Server.handle(Server.java:324)
    	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
    	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:865)
    	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
    	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
    	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
    	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
    Trends trends = twitter.searchOperations().getCurrentTrends();

    Error:

    Code:
    WARNING: GET request for "https://api.twitter.com/1/trends/current.json" resulted in 410 (Gone); invoking error handler
    2011-10-13 12:30:18.640::WARN:  /campaignify/twitter/trends/current
    org.springframework.social.UncategorizedApiException: Error consuming Twitter REST API
            at org.springframework.social.twitter.api.impl.TwitterErrorHandler.handleError(TwitterErrorHandler.java:65)
            at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:486)
            at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:443)
            at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:415)
            at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:213)
            at org.springframework.social.twitter.api.impl.SearchTemplate.getCurrentTrends(SearchTemplate.java:98)
            at org.springframework.social.twitter.api.impl.SearchTemplate.getCurrentTrends(SearchTemplate.java:93)
            at com.campaign.controller.TwitterController.showTrends(TwitterController.java:86)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
            at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
            at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
            at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
            at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
            at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
            at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    Also LocalTrends --> getQuery() Show unwanted special characters E.g.

    Nameennis Ritchie
    Query:%22Dennis%20Ritchie%22
    Nameear Blackberry
    Query:%22Dear%20Blackberry%22

    Please suggest (Using social version 1.0.1.BUILD-SCREENSHOT).

  • #2
    There are 2 distinct issues here, both stemming from some recent changes that Twitter has made to their API:

    First, the issue with the daily trends is that Twitter has changed the date format in the JSON returned. It used to include the seconds in the time (which were always :00), but now it doesn't send the seconds. I've changed the parser's format to accommodate the new format and have created/closed https://jira.springsource.org/browse/SOCIALTW-14 to track this issue.

    The second problem is that Twitter has deprecated the trends/current endpoint. And when they say "deprecated", they do so with an HTTP 410. They say that this endpoint is deprecated in favor of the /trends/:woeid endpoint (although, I don't know that this is the same thing semantically), which is handled by the getLocalTrends() method in SearchOperations. So, I recommend you use getLocalTrends() and I've removed the getCurrentTrends() method and track this with https://jira.springsource.org/browse/SOCIALTW-15.

    The third item isn't an issue at all...it's expected behavior. The query property on Trends will contain a URL-ready String for you to put into the search endpoint. It is escaped so that you won't have to do it yourself. If you want to see the unescaped value (for display purposes), you should use the name property instead.

    Comment

    Working...
    X