android - How can I get the username or email address from oauth? -


i'm using oauth in android application log in it. extract username or email address after successfull logging in? there way it? if yes - how?

i found this: extracting gmail username oauth access token don't know how use it

well digg internet till end , come this:

 private string usernamereader() {         string jsonoutput = "";         try {             jsonoutput = makesecuredreq(constants.api_request, getconsumer(this.prefs));             jsonobject jsonresponse = new jsonobject(jsonoutput);             jsonobject m = (jsonobject) jsonresponse.get("feed");             jsonobject email = (jsonobject) m.get("id");             jsonoutput=email.getstring("$t");         } catch (exception e) {             log.e("errroro", "error executing request", e);             //  console.settext("error retrieving contacts : " + jsonoutput);         }         return jsonoutput;     }      private string makesecuredreq(string url, oauthconsumer consumer) throws exception {         defaulthttpclient httpclient = new defaulthttpclient();         httpget request = new httpget(url);         log.i("requesting", "requesting url : " + url);         consumer.sign(request);         httpresponse response = httpclient.execute(request);         log.i("statusline", "statusline : " + response.getstatusline());         inputstream data = response.getentity().getcontent();         bufferedreader bufferedreader = new bufferedreader(new inputstreamreader(data));         string responeline;         stringbuilder responsebuilder = new stringbuilder();         while ((responeline = bufferedreader.readline()) != null) {             responsebuilder.append(responeline);         }         // log.i(c.tag,"response : " + responsebuilder.tostring());         return responsebuilder.tostring();     }      private oauthconsumer getconsumer(sharedpreferences prefs) {         string token = prefs.getstring(oauth.oauth_token, "");         string secret = prefs.getstring(oauth.oauth_token_secret, "");         oauthconsumer consumer = new commonshttpoauthconsumer(constants.consumer_key, constants.consumer_secret);         consumer.settokenwithsecret(token, secret);         return consumer;     } 

it modified version of http://androidwarzone.blogspot.com/2011/07/android-oauth-full-example-with-source.html

nevertheless, thank william carter time , effort.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -