Mono Support twitter connector 

Viewed 44929 time(s), 3 post(s), 3/25/2011 7:41:32 AM - by geneboss
3/25/2011 7:41:32 AM
189 Reputation 19 Total posts

Hi there,
I want to create my own twitter and facebook connector instead of the current "janrain".
Can this be done?

Thank you in advance
Geneboss

1
3/25/2011 9:18:34 AM
15993 Reputation 2214 Total posts

Hi Geneboss,

"janrain" like Twitter connector can be implemented to get you started here are some links:

Twitter C# Library - http://code.google.com/p/twitterizer/ (New site: http://www.twitterizer.net/)
Integrating Twitter Into An ASP.NET Website - http://www.4guysfromrolla.com/articles/021710-1.aspx


After you perform all necessary steps with Twitter connector and get all the data from Twitter you need to follow these steps to enable the user MonoX usage:

 1. Create or Update a user in MonoX system 
 2. Put user in default roles
 3. Login the user 

Here is a sample code to do some of the above tasks

authenticatedUser = Membership.GetUser(providerUserKey);
if (authenticatedUser == null)
{
  string userNameToUse = SecurityUtility.FindAvailableUserName(preferredName);
  MembershipCreateStatus membershipCreateStatus;
  MembershipUser authenticatedUser = Membership.CreateUser(userNameToUse, SecurityUtility.GenerateRandomPassword(), eMail, "PasswordQuestion", preferredName, true, providerUserKey, out membershipCreateStatus);
  //add user to default user role id it exists
  try
  {
    foreach (string role in MonoXUtility.SplitConfigurationString(ApplicationSettings.DefaultUserRoles))
    Roles.AddUserToRole(userNameToUse, role);
  }
  catch { }
}
else
{
  //update e-mail address if it has changed
  if (!string.IsNullOrEmpty(eMail) && authenticatedUser.Email != eMail)
  {
    authenticatedUser.Email = eMail;
    Membership.UpdateUser(authenticatedUser);
  }
}
 
// Use FormsAuthentication to tell ASP.NET that the user is now logged in, 
// with the OpenID Claimed Identifier as their username.
FormsAuthentication.RedirectFromLoginPage(authenticatedUser.UserName, false);

I hope this will get you started if you have any additional questions feel free to post them here

Regards

2
3/25/2011 4:00:10 PM
189 Reputation 19 Total posts

Thank you for the quick response Khorvat.

Regards
Geneboss

3
This is a demo site for MonoX. Please visit Mono Software for more info.