Email of Twitter User in Twitter4j - java

Can twitter4j get the email of twitter users authorizing an application/web site.
I was able to get the screen name as below:
User user = twitter.showUser(id);
String screenName = user.getScreenName();
How about the email? Is it possible?
Thanks.

You can get the user details using the below API: http://api.twitter.com/1/users/lookup.xml?user_id=YOUR_USER_ID
Twitter says it doesn't provide any API for email retrieval. https://dev.twitter.com/docs/faq#6718

Related

How to get twitter user account email using Java scribe api's

I am creating a twitter social login feature for my Java web application, am using the Scribe library.
Following the library tutorial here for verifying the user credentials, you will be able to retrieve the user credential as json object.
The retrieved json object doesn't have the user email, after researching for how to retrieve the email, i found this documentation in twitter api's.
Now, translating the document with the scribe api's didn't work, and still not able to get the email.
I tried all of the following:
OAuthRequest request = new OAuthRequest(Verb.GET, "https://api.twitter.com/1.1/account/verify_credentials.json");
request.addBodyParameter("include_email", "true");
//OR
request.addQuerystringParameter("include_email", "true");
service.signRequest(accessToken, request);
Response response = request.send();
String result = response.getBody();
Any idea how to retrieve the email using scribe will be appreciated.
Regards

Using facebook RestFB API in JAVA

I'm using RestFB facebook API in JAVA.
What i need to do is to get: users likes,users friends list, users friends likes.
what is the right flow to do it?
Do i need to build an application on facebook that the users will approve and then connect to this application?
I'm very confused with the correct way to implement it :|
thanks!
There's a step by step guide on facebook developers website.
You have to work with an access token that will allow you to use a user's facebook account. Once you've the access, call the appropriate api with user permission to fetch information like basic profile info, friends list, photo, etc.
The RestFB api is open source and is quite good, I haven't had the chance to work with it yet but before using it create a Facebook application and request an OAuth access token. And then proceed as illustrated on the RestFB page.
Something like this:
FacebookClient facebookClient = new DefaultFacebookClient(YOUR_ACCESS_TOKEN);
User user = facebookClient.fetchObject("me", User.class);
Page page = facebookClient.fetchObject("cocacola", Page.class);
out.println("User name: " + user.getName());
out.println("Page likes: " + page.getLikes());

Verifying entered email address in Java Application for Google App Engine

I have a Java Web Application that gets information from the user. Before processing the information I wanted to make sure the email entered by the user belongs to the community.
I was originally going to have a file listing everyone int the community's email address. Upon submit, grab the email and ensure it exists in the master file.
Can anyone recommend how to do this with Google App Engine platform?
Thanks so much!
UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();
if (user == null) {
response.sendRedirect( "/login" );
}
out.print( user.getNickname() );
You can obtain the email address from the User class above. The code above checks if a user is already logged into the google account. There is Open authorization protocol that would enable you to see if the visitor is already logged into a site that supports oAuth protocol (like Facebook etc).

Get twitter email Id on my web site

How can I get twitter email Id on my web site.
I am using twitter4j api.
But while getting email it shows
Email: Twitter does not provide this!
In twitter4j api no method available to get email
user = twitter.showUser(twitter.getId());
twitterUser = new TwitterUser(user.getId(),user.getName(),user.getScreenName(),user.getLocation(),
user.getDescription(),user.getProfileImageURL().toString(),
user.getFollowersCount(),user.getFriendsCount(),user.getFavouritesCount(),user.getStatusesCount(),
user.getListedCount(),user.getCreatedAt().toString(),user.getTimeZone(),user.getUtcOffset(),
user.getLang(),user.getURL()!=null?user.getURL().toString():null);
Is there any way to get this.
Is there any othe api to get email and /FirstName/LastName .
Please suggest any solution for this.
Twitter does not provide an API for email retrieval. From their FAQ:
How do I obtain a user's email address?
If you'd like a user's email address, you'll need to ask a user for it within the confines of your own application and service. The Twitter API does not provide the user's email address as part of the OAuth token negotiation process nor does it offer other means to obtain it.
If you have a user's ID or screen name, you can get any additional information from the Twitter4J User interface.

User info from token

My application uses 3-legged authentication (OAuth).
I have the token (user was redirected to google login page to log in)
How can I get the e-mail address he used to authenticate?
you should look up user data using the access token. in facebook, the access token starts with user serial, so you can identify user from token directly. (ex. 123456-someStrangeStringBlahBlah...)
so if exposure of user serial is not problem, make token like facebook.
I think you want to use OpenID attribute exchange. (not OAuth, but Google has a bridge between the two).
See Google's page on their federated login API.
If you are using OAuth1.0 you can extract user email from the contactService by making a request to get for example contact group id. The returned response contains the user email encoded:
"http://www.google.com/m8/feeds/groups/user_email_here%40gmail.com/base/5f062e1e08cb3123"

Categories

Resources