Skip to content

Instantly share code, notes, and snippets.

View ryanvalentin's full-sized avatar

Ryan Valentin ryanvalentin

View GitHub Profile
@ryanvalentin
ryanvalentin / threads_set.cs
Last active January 2, 2016 21:09
How to make a Disqus API call to threads/set to get an unsorted array of threads you specified
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
namespace Example
@ryanvalentin
ryanvalentin / blogger-ident.html
Last active December 25, 2015 20:09
Get identifier from Blogger and output as 'disqus_identifier'
<div id="disqus_thread" onresize="setHeight()"></div>
<script type="text/javascript">
// Blog variables
var blog;
var msg = new gadgets.MiniMessage(__MODULE_ID__);
var prefs = new gadgets.Prefs();
// Disqus variables
var disqus_shortname = prefs.getString("shortname");
@ryanvalentin
ryanvalentin / disqus-wp-webview.cs
Last active February 9, 2025 04:19
Using Disqus in a WebBrowser control in Windows
// 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
@ryanvalentin
ryanvalentin / gist:5987676
Last active December 19, 2015 16:59
Check Disqus for identifier conflicts before loading
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
var disqus_shortname = 'YOUR_DISQUS_SHORTNAME'; // required: replace example with your forum shortname
var disqus_identifier = 'THE_DISQUS_IDENTIFIER';
var disqus_url = 'THE_PAGE_URL';
var disqus_public_key = 'YOUR_API_PUBLIC_KEY'; // Get one at http://disqus.com/api/applications/
$(document).ready(function () {
var req = $.ajax({
@ryanvalentin
ryanvalentin / gist:5768367
Last active December 18, 2015 10:28
Post a guest comment through the Disqus API
/// <summary>
/// Method to post a new comment
/// </summary>
public static async Task<string> PostComment(string threadid, string message, string guestemail, string guestname)
{
if (!NetworkInterface.GetIsNetworkAvailable())
return "Error: Not connected to the internet";
// Create HTTP client
var gziphandler = new CompressedHttpClientHandler();
@ryanvalentin
ryanvalentin / gist:5767814
Created June 12, 2013 18:26
Windows Phone Disqus Embed
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
@ryanvalentin
ryanvalentin / DisqusWPExample.cs
Last active December 17, 2015 08:09
Disqus API methods for guest commenting Windows Phone
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using System.Net.NetworkInformation;
using System.Net.Http;
using AdvancedREI.Net.Http.Compression;
using example_project.Resources;
@ryanvalentin
ryanvalentin / gist:5416921
Created April 18, 2013 23:07
Generate Disqus SSO payload using Python
import base64
import hashlib
import hmac
import simplejson
import time
DISQUS_SECRET_KEY = '123456'
DISQUS_PUBLIC_KEY = 'abcdef'
def get_disqus_sso(user):
@ryanvalentin
ryanvalentin / gist:5416919
Created April 18, 2013 23:06
Generate Disqus SSO payload using PHP
<?php
define('DISQUS_SECRET_KEY', '123456');
define('DISQUS_PUBLIC_KEY', 'abcdef');
$data = array(
"id" => $user["id"],
"username" => $user["username"],
"email" => $user["email"]
);
@ryanvalentin
ryanvalentin / gist:5416892
Created April 18, 2013 22:59
Generate a Disqus SSO payload with Coldfusion
<cfcomponent displayname="Comment" hint="Disqus Interface">
<cfset VARIABLES.stcMemberInfo = StructNew() />
<cfset VARIABLES.intUnixTimestamp = DateDiff("s", CreateDate(1970,1,1), Now()) />
<cfset VARIABLES.stgPublicKey = "">
<cfset VARIABLES.stgPrivateKey = "">
<cfset VARIABLES.stgForumShortName = "">
<cfset getMemberInfo() >