2016-12-14 48 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