Announcement Announcement Module
Collapse
No announcement yet.
Send a Request to Multiple Users on Facebook Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Send a Request to Multiple Users on Facebook

    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
    Last edited by Laedislaw; Nov 28th, 2012, 11:34 AM.

  • #2
    I could be wrong, but...Put simply, you cannot send app requests via the Graph API (and thus cannot send them via Spring Social). If you could, then it opens up the opportunity for an application to abuse the feature to spam other users just because one of their friends (soon to be former friend) authorized it.

    Also, one clue to the fact that it's not supported in the Graph API is that there is no extended permission for that case at https://developers.facebook.com/docs...d-permissions/.

    The only way to do this is to have the user explicitly submit the invitation via Facebook's Javascript library. The link you mentioned describes how you do that with FB.ui().

    Comment

    Working...
    X