Announcement Announcement Module
Collapse
No announcement yet.
Issue while Posting on Facebook wall Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Issue while Posting on Facebook wall

    I am using Spring Social and want to update Status on Facebook through my application. I am new to this area and able to run one POC sample (got from web) to read friend Names if user authorize my application (OAuth2 - https://graph.facebook.com/oauth/access_token). Now when I am trying to post following reference example in Spring Social facebook reference (1.0.0) I am getting below error:

    Reference Code:
    Code:
          Facebook facebook = new FacebookTemplate(token.getValue());
          facebook.feedOperations().updateStatus("I'm trying out Spring Social!");
    Error:
    Code:
    (#200) The user hasn't authorized the application to perform this action
    
    org.springframework.social.OperationNotPermittedException: (#200) The user hasn't authorized the application to perform this action
    	at org.springframework.social.facebook.api.impl.FacebookErrorHandler.handleFacebookError(FacebookErrorHandler.java:123)
    	at org.springframework.social.facebook.api.impl.FacebookErrorHandler.handleError(FacebookErrorHandler.java:60)
    	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.postForObject(RestTemplate.java:294)
    	at org.springframework.social.facebook.api.impl.FacebookTemplate.publish(FacebookTemplate.java:198)
    	at org.springframework.social.facebook.api.impl.FeedTemplate.post(FeedTemplate.java:185)
    	at org.springframework.social.facebook.api.impl.FeedTemplate.updateStatus(FeedTemplate.java:163)
    	at com.campaignify.oauth.client.mvc.FacebookController.handleRequestInternal(FacebookController.java:49)
    	at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
    	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
    	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:644)
    	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
    	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)
    Please suggest how to request user for authorizing posting on Facebook wall through my application. I tried few combination to this via https://developers.facebook.com but no luck.

  • #2
    Facebook's authorization scheme is rich with several permissions you can ask for when authorizing (see http://developers.facebook.com/docs/...i/permissions/). When you ask the user to authorize your application (just before you get the access token), you need to request "publish_stream" permission if you want to be able post to the user's wall.

    If you're using Spring Social's ConnectController to handle authorization, you just need to put in a hidden field named "scope" in the form that kicks off the connection flow with the desired permission(s) as the value. Refer to https://github.com/SpringSource/spri...ookConnect.jsp for an example of how this is done.

    Comment


    • #3
      Thanks a lot for input.
      I was able to resolve the issue and update status/Feed Link on Facebook through my application.

      Comment


      • #4
        Originally posted by Shishir.Kumar View Post
        Thanks a lot for input.
        I was able to resolve the issue and update status/Feed Link on Facebook through my application.
        can you share how you ressolved this? I got the same problem

        Comment


        • #5
          Client application need to get resource owners permission before posting on Wall/Status. You need to get "publish_stream" permission to post on facebook wall.

          Code:
          E.g. 
          <input type="hidden" name="scope" value="publish_stream,user_photos,offline_access" />
          You can refer "spring-social-showcase" sample project for reference https://github.com/SpringSource/spri...ocial-showcase
          JSP: https://github.com/SpringSource/spri...ookConnect.jsp

          Also Facebook permission detail can be found at http://developers.facebook.com/docs/...i/permissions/

          Comment


          • #6
            Originally posted by Shishir.Kumar View Post
            Client application need to get resource owners permission before posting on Wall/Status. You need to get "publish_stream" permission to post on facebook wall.

            Code:
            E.g. 
            <input type="hidden" name="scope" value="publish_stream,user_photos,offline_access" />
            You can refer "spring-social-showcase" sample project for reference https://github.com/SpringSource/spri...ocial-showcase
            JSP: https://github.com/SpringSource/spri...ookConnect.jsp

            Also Facebook permission detail can be found at http://developers.facebook.com/docs/...i/permissions/
            Hi Kumar, and rest of spring members,

            The way I am doing the posting of message to facebook is like this inside my controller.
            how do i put this in a picture? "<input type="hidden" name="scope" value="publish_stream,user_photos,offline_access" />"

            String apiKey = "XXXXXX";
            String apiSecret = "XXXXXX";
            OAuthService service = new ServiceBuilder()
            .provider(FacebookApi.class)
            .apiKey(apiKey)
            .apiSecret(apiSecret)
            .callback("http://localhost:8888/xxxx/xxxx.htm")
            .build();

            String authorizationUrl = service.getAuthorizationUrl(null);
            Verifier verifier = new Verifier("xxxxxxxxx");
            Token accessToken = service.getAccessToken(null, verifier);
            String token = accessToken.getToken();

            System.out.println("Now we're going to access a protected resource...");
            OAuthRequest req = new OAuthRequest(Verb.GET,"https://graph.facebook.com/me");
            service.signRequest(accessToken, req);
            Response res = req.send();

            FacebookTemplate facebookTemplate = new FacebookTemplate(token);
            facebookTemplate.feedOperations().updateStatus("Te st message - SENT via lightyears's software");

            Comment

            Working...
            X