Mono Support twitter connector 

43555 put(a) pogledan, 3 odgovor(a), 25.3.2011. 7:41:32 - Kreirao(la) geneboss
25.3.2011. 7:41:32
189 Reputacija 19 Ukupno objava

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
25.3.2011. 9:18:34
15993 Reputacija 2214 Ukupno objava

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
25.3.2011. 16:00:10
189 Reputacija 19 Ukupno objava

Thank you for the quick response Khorvat.

Regards
Geneboss

3
Ovo je MonoX demo site. Posjetite Mono Software za više detalja.