Digg’s new API is impressive. Incorporating your digg user account activity or your domain’s popular posts into your blog or using it as part of a micro blogging strategy is a snap. The easiest way I have found is to use Nick Halstead’s Simple Digg API Usage script. This script doesn’t require PEAR and it works on PHP 4 & 5.
Digg User Lookup
The Basics
To get started, you need to create (as in ‘out of thin air’) an application key and a user agent. There is no application key signup like Google or Youtube, however the application key you choose should meet the following requirements:
from the digg api wiki
The value of the appkey argument must be a valid absolute URI (see IETF RFC 2396) that identifies the application making the request. The URI might point to:
- The application itself, if it’s a web application.
- A web page describing the application.
- A web page offering the application for download.
- The author’s web site.
Html
The html for the form to display to request digg user name.
<form action="" method="post">
<table border="0">
<thead>
<tr>
<td colspan="2">User Lookup</td>
</tr>
</thead>
<tbody>
<tr>
<td>User Name</td>
<td>
<input maxlength="50" name="uid" size="25" type="text" /></td>
</tr>
<tr>
<td></td>
<td><input name="submit" type="submit" value="submit" /></td>
</tr>
</tbody>
</table>
</form>
Code
The backend code to function the submit request
decode($response);
foreach($decoded->users as &$user) {
// $user = $decoded->users;
$name = $user->name;
$icon = $user->icon;
$registered = $user->registered;
$profileviews = $user->profileviews;
function timestamp_to_date ($registered)
{
$date = date ('m-d-Y' , $registered);
echo $date;
}
echo "<div id=\"archivebox\">";
echo "<h2><img src="\" alt="" />";
echo "$name";
echo "User Since: ";
timestamp_to_date ($registered);
echo "";
echo "Profile Views: $profileviews ";
echo "</h2><h3>User Links</h3>";
echo "<ul>";
}
foreach($user->links as $link) {
$href = $link->href;
$description = $link->description;
echo "<li><a href="$href">$description</a></li>";
}
echo "</ul>";
echo "</div>";
} else { //form hasn't been submitted
$user = "elebrio";
require("JSON.php");
ini_set('user_agent', 'ic/1.0');
$appkey = 'http://indexedcontent.com';
$response = file_get_contents("http://services.digg.com/user/$user?appkey=$appkey&type=json");
$json = new Services_JSON();
$decoded = $json->decode($response);
foreach($decoded->users as &$user) {
// $user = $decoded->users;
$name = $user->name;
$icon = $user->icon;
$registered = $user->registered;
$profileviews = $user->profileviews;
function timestamp_to_date ($registered)
{
$date = date ('m-d-Y' , $registered);
echo $date;
}
echo "<div id=\"archivebox\">";
echo "<h2><img src="\" alt="" />";
echo "$name";
echo "User Since: ";
timestamp_to_date ($registered);
echo "";
echo "Profile Views: $profileviews ";
echo "</h2><h3>User Links</h3>";
echo "<ul>";
}
foreach($user->links as $link) {
$href = $link->href;
$description = $link->description;
echo "<li><a href="$href">$description</a></li>";
}
echo "</ul>";
echo "</div>";
}
?>
In order to get this code working on your site, you will need to change two variables.
- appkey - replace with your domain
$appkey ='http://indexedcontent.com';
- user agent
ini_set('user_agent', 'ic/1.0');ic/1.0 is my site’s current user agent. You can basically name this whatever you want.

