Last active
February 9, 2025 04:19
-
-
Save ryanvalentin/6124471 to your computer and use it in GitHub Desktop.
Using Disqus in a WebBrowser control in Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Url of Comments page | |
private string CommentsUri = "http://yoursite.com/comments/your_static_comments_page.html?" | |
+ "shortname=" + "YOUR_SHORTNAME" | |
+ "&url=" + HttpUtility.UrlEncode("ORIGINAL_ARTICLE_URL") | |
+ "&title=" + HttpUtility.UrlEncode("ORIGINAL_ARTICLE_TITLE") | |
+ "&identifier=" + HttpUtility.UrlEncode("ORIGINAL_ARTICLE_IDENTIFIER"); | |
private void Browser_Loaded(object sender, RoutedEventArgs e) | |
{ | |
Browser.IsScriptEnabled = true; // Make sure javascript is enabled | |
Browser.Navigate(new Uri(CommentsUri, UriKind.Absolute)); | |
} | |
// Event that fires when the browser finishes loading a page | |
private void Browser_Navigated(object sender, NavigationEventArgs e) | |
{ | |
// Get the current window's URL string | |
string navigatedUri = e.Uri.OriginalString.ToLowerInvariant(); | |
// Array of URLs that indicate the user has just logged in | |
string[] patterns = { "disqus.com/next/login-success", "disqus.com/_ax/google/complete", "disqus.com/_ax/twitter/complete", "disqus.com/_ax/facebook/complete" }; | |
if (patterns.Any(navigatedUri.Contains)) | |
{ | |
// If there was a match, go back to the comment thread | |
Browser.Navigate(new Uri(CommentsUri, UriKind.Absolute)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The "CommentsUri" should point to a hosted page on your site that uses this template: https://github.com/disqus/DISQUS-API-Recipes/blob/master/mobile/js/mobiletemplate.html