2011-01-28 16 views
1

私はdotnetopenauthライブラリを使用しています。私はコールバックURLを変更する方法を理解しようとしています。私は、サンプルファイルdotnetopenauth - twitterのコールバックURLを変更しますか?

public partial class SignInWithTwitter : System.Web.UI.Page { 
     protected void Page_Load(object sender, EventArgs e) { 
      if (TwitterConsumer.IsTwitterConsumerConfigured) { 
       this.MultiView1.ActiveViewIndex = 1; 

       if (!IsPostBack) { 
        string screenName; 
        int userId; 
        if (TwitterConsumer.TryFinishSignInWithTwitter(out screenName, out userId)) { 
         this.loggedInPanel.Visible = true; 
         this.loggedInName.Text = screenName; 

         // In a real app, the Twitter username would likely be used 
         // to log the user into the application. 
         ////FormsAuthentication.RedirectFromLoginPage(screenName, false); 
        } 
       } 
      } 
     } 

     protected void signInButton_Click(object sender, ImageClickEventArgs e) { 
      TwitterConsumer.StartSignInWithTwitter(this.forceLoginCheckbox.Checked).Send(); 

     } 

で探しています

だから、これは(MVCのためのわずかに異なるWebフォーム用)のTwitterへオフ要求を送信するために必要なものすべてをです。

私は、私はむしろ別のアクションの結果を持っている(レスポンスがあまりにも戻ってくるURLを変更したいと思います。

今ではStartSignInWithTwitter(ように思える)、それはURLを設定します場所です。

/// <summary> 
    /// Prepares a redirect that will send the user to Twitter to sign in. 
    /// </summary> 
    /// <param name="forceNewLogin">if set to <c>true</c> the user will be required to re-enter their Twitter credentials even if already logged in to Twitter.</param> 
    /// <returns>The redirect message.</returns> 
    /// <remarks> 
    /// Call <see cref="OutgoingWebResponse.Send"/> or 
    /// <c>return StartSignInWithTwitter().<see cref="MessagingUtilities.AsActionResult">AsActionResult()</see></c> 
    /// to actually perform the redirect. 
    /// </remarks> 
    public static OutgoingWebResponse StartSignInWithTwitter(bool forceNewLogin) { 
     var redirectParameters = new Dictionary<string, string>(); 
     if (forceNewLogin) { 
      redirectParameters["force_login"] = "true"; 
     } 
     Uri callback = MessagingUtilities.GetRequestUrlFromContext().StripQueryArgumentsWithPrefix("oauth_"); 
     var request = TwitterSignIn.PrepareRequestUserAuthorization(callback, null, redirectParameters); 
     return TwitterSignIn.Channel.PrepareResponse(request); 
    } 

それは難しい状況から現在の要求を取得するためにコード化しているようだ。私は実際にこのコード行を変更すると.dllを再コンパイルせずに何とかこれを上書きすることが可能ですか?

編集 今、私は.dllに変更を加えました - 私はカスタムバージョンをサポートする必要があるので、この方法が本当に好きではありません。

public static OutgoingWebResponse StartSignInWithTwitter(bool forceNewLogin) { 
    Uri callback = MessagingUtilities.GetRequestUrlFromContext().StripQueryArgumentsWithPrefix("oauth_"); 
    return StartProcess(forceNewLogin, callback); 
    } 

private static OutgoingWebResponse StartProcess(bool forceNewLogin, Uri callback) 
{ 
    var redirectParameters = new Dictionary<string, string>(); 
    if (forceNewLogin) 
    { 
     redirectParameters["force_login"] = "true"; 
    } 
    var request = TwitterSignIn.PrepareRequestUserAuthorization(callback, null, redirectParameters); 
    return TwitterSignIn.Channel.PrepareResponse(request); 
} 

public static OutgoingWebResponse StartSignInWithTwitter(bool forceNewLogin, Uri callback) 
{ 
    return StartProcess(forceNewLogin, callback); 
} 

うまくいけば別の方法があります。

答えて

2

ライブラリを再コンパイルしないようにお願いします。しかし、DotNetOpenAuth.ApplicationBlockライブラリは、DotNetOpenAuthの単なる補助ライブラリであり、実際にそのまま使用することは意図されていないため、ソースとともに出荷されます。ソースコードをコピーして必要なWebアプリケーションに貼り付け、残りをダンプすることが期待されています。たとえば、コアdotnetopenauth.dllファイルにあるように、バージョン間でアプリケーションブロックライブラリに下位互換性の約束はありません。

アプリブロックが不足していると思われる場合は、あなた自身で修正する権利があります。

+0

なぜそれがナゲットに上がらないのか説明しています。さて、私は最後にしようとすることは、Facebookの仕事を得ることですが、私はCTPを見つけることができませんあなたが話している場所。 http://stackoverflow.com/questions/4821747/facebook-twitter-with-dotnetopenauth – chobo2

関連する問題