Skip to content

Instantly share code, notes, and snippets.

@robbiet480
Created May 6, 2011 18:16
Show Gist options
  • Save robbiet480/959473 to your computer and use it in GitHub Desktop.
Save robbiet480/959473 to your computer and use it in GitHub Desktop.
delicious.php
<?php
/**
* @link http://gist.github.com/385876
*/
function csv_to_array($filename='', $delimiter=',')
{
if(!file_exists($filename) || !is_readable($filename))
return FALSE;
$header = NULL;
$data = array();
if (($handle = fopen($filename, 'r')) !== FALSE)
{
while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
{
if(!$header)
$header = $row;
else
$data[] = array_combine($header, $row);
}
fclose($handle);
}
return $data;
}
$arr = csv_to_array($argv[1],',');
foreach($arr as $user) {
$url = "http://feeds.delicious.com/v2/rss/".$user['Username']."?count=1500";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$myFile = "users/".$user['Username'].".txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $output);
fclose($fh);
$myFile = "log.csv";
$fh = fopen($myFile, 'a') or die("can't open file");
fwrite($fh, $user['Username'].",".$url.",".date('r')."\n");
fclose($fh);
echo "\n".$user['Username']."\n";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment