2016-12-14 62 views
0

我正在使用Xamarin.Auth与Twitter进行身份验证。我使用下面的代码来授权:发布推文[Xamarin.Android]

private void LoginTwitter() { 
    var auth = new OAuth1Authenticator(
     consumerKey: "KEY", 
     consumerSecret: "SECRET", 
     requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"), 
     authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"), 
     accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"), 
     callbackUrl: new Uri("http://mobile.twitter.com") 
    ); 

    auth.Completed += twitter_auth_Completed; 
    StartActivity(auth.GetUI(this)); 
} 

private void twitter_auth_Completed(object sender, AuthenticatorCompletedEventArgs eventArgs) { 
    if (eventArgs.IsAuthenticated) { 
     Toast.MakeText(this, "Logged in!", ToastLength.Long).Show();  
    } 
} 

授权正在工作,但我现在想要在Twitter上发布推文。

授权后做这件事的最好方法是什么?

谢谢。

+4

Xamarin.Auth仅仅是Authentication(也就是检验一个人是在Twitter上的现有用户/库。 ..)。对于实际发布,你必须使用twitters自己的api。 –

回答

0

如果你与iOS的工作,用社会框架:https://developer.xamarin.com/guides/ios/platform_features/introduction_to_the_social_framework/

对于Android,iOS或跨平台的,你可以使用像LinqToTwitter(https://github.com/JoeMayo/LinqToTwitter/wiki)。这是与Android的演练:http://geekswithblogs.net/WinAZ/archive/2013/11/14/linq-to-twitter-runs-xamarin.android.aspx

这里有一个社区视频中介绍了一些选项:https://www.youtube.com/watch?v=6w_OwswzZb4

+0

啊,只是注意到你指定了Android :)。 LinqToTwitter是我的建议,留下其他链接,以防万一您决定跨平台。 – vyedin