Advertisement
Guest User

Untitled

a guest
Feb 21st, 2013
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. <a href="https://www.facebook.com/dialog/oauth?client_id=something&redirect_uri=http://our.domaine.register/postback?user_id=12345&scope=manage_pages&response_type=code">connect</a>
  2.  
  3. our.domaine.register/postback?user_id=12345&code=SoMEcOde
  4.  
  5. @RequestMapping(value = "/postback", params = "code", method = RequestMethod.GET)
  6. @ResponseBody
  7. private void accessCode(@RequestParam("code") String code,
  8. HttpServletRequest request,
  9. HttpServletResponse response) throws Exception {
  10. //Now the variable 'code' holds the authorization code
  11. }
  12.  
  13. https://www.facebook.com/dialog/oauth?
  14. client_id=YOUR_APP_ID
  15. &redirect_uri=https://www.facebook.com/connect/login_success.html
  16. &response_type=token
  17.  
  18. public static Bundle decodeUrl(String s) {
  19. Bundle params = new Bundle();
  20. if (s != null) {
  21. String array[] = s.split("&");
  22. for (String parameter : array) {
  23. String v[] = parameter.split("=");
  24. // YG: in case param has no value
  25. if (v.length==2){
  26. params.putString(URLDecoder.decode(v[0]),
  27. URLDecoder.decode(v[1]));
  28. }
  29. else {
  30. params.putString(URLDecoder.decode(v[0])," ");
  31. }
  32. }
  33. }
  34. return params;
  35. }
  36.  
  37. /**
  38. * Parse a URL query and fragment parameters into a key-value bundle.
  39. *
  40. * @param url the URL to parse
  41. * @return a dictionary bundle of keys and values
  42. */
  43. public static Bundle parseUrl(String url) {
  44.  
  45. try {
  46. URL u = new URL(url);
  47. Bundle b = decodeUrl(u.getQuery());
  48. b.putAll(decodeUrl(u.getRef()));
  49. return b;
  50. } catch (MalformedURLException e) {
  51. Log.w(TAG, "parseUrl ex ->" + e.toString());
  52. return new Bundle();
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement