Quantcast
Channel: Spring Community Forums - Social
Viewing all articles
Browse latest Browse all 145

Send a Request to Multiple Users on Facebook

$
0
0
Hi

I'd like to implement an App Request feautre to enable users to send invites to facebook friends.

I pasted below progress so far (not much), throws an error, not sure why?: org.springframework.social.OperationNotPermittedEx ception: (#200) All users in param ids must have accepted TOS.

I'd like it to be "Multiple Friend Selector" where users select one or more people from the request dialog window see - http://developers.facebook.com/blog/post/453/

I'm not sure how to make the "request dialog window" you see in the link (provided above) appear when user clicks on a "invite friend" button. In addition the publish() method below only takes a single id as opposed to a list of ids.

Looking for some pointers on how to achieve the above.

Code:


@RequestMapping(value="/facebook/friends/apprequest", method=RequestMethod.GET)
        public String appRequest(Model model) {
                RestTemplate restTemplate = new RestTemplate();
                String clientId= environment.getProperty("facebook.clientId");
                String clientSecret = environment.getProperty("facebook.clientSecret");
               
                String url = "https://graph.facebook.com/oauth/access_token?" +
                                "grant_type=client_credentials&client_id="+clientId+"&client_secret="+clientSecret;

                String result = restTemplate.getForObject(url, String.class);
                String appAccessToken = result.replaceAll("access_token=", "");
                //create the request
                FacebookTemplate appRequestTemplate = new FacebookTemplate(appAccessToken);
                MultiValueMap<String, Object> requestData = new LinkedMultiValueMap<String, Object>();
                String userid = "someID";
                requestData.set("message", "Sending a request through to you.");
                appRequestTemplate.publish(userId, "apprequests", requestData);
               
                //model.addAttribute("message",resultOfAppRequest);
                       
                return "home";
        }

Thanks

Viewing all articles
Browse latest Browse all 145

Trending Articles