Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <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>
- our.domaine.register/postback?user_id=12345&code=SoMEcOde
- @RequestMapping(value = "/postback", params = "code", method = RequestMethod.GET)
- @ResponseBody
- private void accessCode(@RequestParam("code") String code,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- //Now the variable 'code' holds the authorization code
- }
- https://www.facebook.com/dialog/oauth?
- client_id=YOUR_APP_ID
- &redirect_uri=https://www.facebook.com/connect/login_success.html
- &response_type=token
- public static Bundle decodeUrl(String s) {
- Bundle params = new Bundle();
- if (s != null) {
- String array[] = s.split("&");
- for (String parameter : array) {
- String v[] = parameter.split("=");
- // YG: in case param has no value
- if (v.length==2){
- params.putString(URLDecoder.decode(v[0]),
- URLDecoder.decode(v[1]));
- }
- else {
- params.putString(URLDecoder.decode(v[0])," ");
- }
- }
- }
- return params;
- }
- /**
- * Parse a URL query and fragment parameters into a key-value bundle.
- *
- * @param url the URL to parse
- * @return a dictionary bundle of keys and values
- */
- public static Bundle parseUrl(String url) {
- try {
- URL u = new URL(url);
- Bundle b = decodeUrl(u.getQuery());
- b.putAll(decodeUrl(u.getRef()));
- return b;
- } catch (MalformedURLException e) {
- Log.w(TAG, "parseUrl ex ->" + e.toString());
- return new Bundle();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement