Skip to content

Instantly share code, notes, and snippets.

View ryanvalentin's full-sized avatar

Ryan Valentin ryanvalentin

View GitHub Profile
@ryanvalentin
ryanvalentin / gist:5248630
Created March 26, 2013 19:54
Update all thread titles based on Query
<?php
date_default_timezone_set('America/Los_Angeles');
$apikey = '<your disqus secret key>'; // Your Disqus secret key from http://disqus.com/api/
$forum = '<your forum shortname>';
$limit = '100'; // max is 100 for this endpoint. 25 is default
$order = 'asc'; // asc = oldest to newest. default is desc
$since = '1362117600'; // 1362117600 = March 1, 2013 at Midnight
$accessToken = '<your admin access token>'; // Get your access token from your API application page: http://disqus.com/api/applications/
@ryanvalentin
ryanvalentin / gist:5416761
Last active January 12, 2017 16:50
Generate Disqus SSO payload in Java
/*
This script will calculate the Disqus SSO payload package
Please see the Integrating SSO guide to find out how to configure your account first:
http://help.disqus.com/customer/portal/articles/236206
This example uses the Jackson JSON processor: http://jackson.codehaus.org/Home
*/
String DISQUS_SECRET_KEY = "<YOUR_SECRET_KEY>"; // Your Disqus secret key from http://disqus.com/api/applications/
// User data, replace values with authenticated user data
@ryanvalentin
ryanvalentin / gist:5416819
Last active December 16, 2015 09:59
Example usage of the Disqus SSO example class
/*
In your code-behind file, create a new instance of the DisqusSSO class, set the API key and call the generate method. NOTE: The method is overloaded and will optionally accept an avatar URL and/or a profile URL.
Depends on SSO class payload generator found here: https://github.com/disqus/DISQUS-API-Recipes/blob/master/cs/sso/DisqusSSO.cs
*/
public string Payload { get; private set; }
public void GetSSOPayload(bool authenticated)
{
@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() >
@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: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 / 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: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 / 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: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({