Skip to content

Instantly share code, notes, and snippets.

@benubois
Created October 11, 2009 09:58
Show Gist options
  • Save benubois/207575 to your computer and use it in GitHub Desktop.
Save benubois/207575 to your computer and use it in GitHub Desktop.
!#/usr/bin/php
<?php
# Username
$username = '';
# Location of waves.txt file
$waves_txt = '';
# Private key. Optional if you want to include private bookmarks
$private_key = '';
$ch = curl_init('http://feeds.delicious.com/v2/json/' . $username . '/shortcut?count=100&private=' . $private_key);
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CONNECTTIMEOUT => 5,
CURLOPT_TIMEOUT => 10,
CURLOPT_DNS_CACHE_TIMEOUT => 86400
));
$result = curl_exec($ch);
$bookmarks = json_decode($result);
$waves = array();
$keywords = '';
for ($i=0; $i < count($bookmarks); $i++)
{
foreach ($bookmarks[$i]->t as $tag)
{
if (substr($tag, 0, 9) == 'shortcut:')
{
$waves[$i]['keyword'] = substr($tag, 9, strlen($tag));
}
}
$waves[$i]['url'] = $bookmarks[$i]->u;
$waves[$i]['description'] = $bookmarks[$i]->d;
}
foreach ($waves as $wave)
{
$keywords .= implode(' ', $wave) . "\n";
}
echo $keywords;
$file = $waves_txt;
$fh = fopen($file, 'wb');
fwrite($fh, $keywords);
fclose($fh);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment