Skip to content

Instantly share code, notes, and snippets.

@thetylerhayes
thetylerhayes / gist:2034218
Created March 14, 2012 05:05
Use DISQUS forums/listMostActiveUsers to list 100 most active users and comment counts
<?php
ini_set('display_errors', 'on');
// More documentation on this DISQUS API endpoint at http://disqus.com/api/docs/forums/listMostActiveUsers/
$key="<your DISQUS API application key>"; // Requires a registered DISQUS API application. Create one (free) at http://disqus.com/api/applications/
$forum="<DISQUS forum>";
$limit="100"; // list 100 users. max is 100
// construct the query with our API key and the query we want to make
$endpoint = 'http://disqus.com/api/3.0/forums/listMostActiveUsers.json?api_key='.urlencode($key).'&forum='.$forum.'&limit='.$limit;
@thetylerhayes
thetylerhayes / gist:1928253
Created February 28, 2012 00:57
Use DISQUS users/details to get an SSO account's username
<?php
ini_set('display_errors', 'on');
$key="<your DISQUS API application key>"; // Requires a registered DISQUS API application. Create one (free) at http://disqus.com/api/applications/
$remote_domain="<remote domain slug>"; // slug of the remote domain established at http://disqus.com/api/sso/ (the bolded word)
$remote_identifier="<unique ID>"; // unique ID passed in the remote_auth_s3 payload
// For more on unique ID see http://docs.disqus.com/developers/sso/ > "Using HMAC-SHA1 to pass user data" > "The message body (Base64-encoded)" > "id"
// construct the query with our API key and the query we want to make
// FORMAT: user=remote:remote_domain-remote_identifier
@thetylerhayes
thetylerhayes / gist:1909926
Created February 25, 2012 18:18
Use DISQUS threads/details to get a thread's details
<?php
ini_set('display_errors', 'on');
$key="<api key>"; // Requires a registered DISQUS API application. Create one (free) at http://disqus.com/api/applications/
$thread="<DISQUS thread ID>";
$forum="<DISQUS forum shortname>";
// construct the query with our apikey and the query we want to make
// Change api_key to api_secret when using your secret key
/*
@thetylerhayes
thetylerhayes / gist:1878262
Created February 21, 2012 19:18
Use DISQUS threads/list to list all threads created between a given date and now
<?php
date_default_timezone_set('America/Los_Angeles');
$apikey = '<your key here>'; // get keys at http://disqus.com/api/ — can be public or secret for this endpoint
$forum = '<your DISQUS forum shortname>';
$limit = '100'; // max is 100 for this endpoint. 25 is default
$order = 'asc'; // asc = oldest to newest. default is desc
$since = '1320123600'; // 1320123600 = nov 1, 2011 midnight EST
@thetylerhayes
thetylerhayes / gist:1878254
Created February 21, 2012 19:16
Use DISQUS posts/create method to create a guest comment
<?php
ini_set('display_errors', 'on');
$thread="<thread ID goes here>"; // e.g., 455718495 — you'll need to also create a $forum and pass that if you know only the thread's URL or identifier rather than the ID
$api="<key goes here>"; // Generate one at http://disqus.com/api/applications/ -- Secret key is required for anonymous comment posting
$message="Hello world."; // this is the content of the comment, i.e., what you'd normally type in the postbox
$author_email="sample@disqus.com"; // optional, including this will still make the comment a guest comment, but it will now be claimable
$author_name="Bruce Wayne"; // optional, can be any display name you like
$fields_string=""; // DO NOT EDIT
@thetylerhayes
thetylerhayes / gist:1619194
Created January 16, 2012 05:21
Enable multiple checkboxes using JavaScript and jQuery
var script = document.createElement('script')
script.src = 'http://code.jquery.com/jquery.js'
document.head.appendChild(script)
$('.container').find('.child-class').find('input[type="checkbox"]').attr('checked', true);
@thetylerhayes
thetylerhayes / Omit PHP extension
Created January 4, 2012 22:28
Redirect to PHP if it exists (i.e., omit PHP extension)
# Redirect to PHP if it exists.
# e.g. example.com/foo will display the contents of example.com/foo.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]