del.icio.us user '
. $attrs["USER"]
. " on " . $attrs["DT"] . ":\n
\n";
$wp_excerpt = 'Shared bookmarks for del.icio.us user '
. $attrs["USER"]
. " on " . $attrs["DT"] . "...";
}
else {
$content = $content . 'Shared bookmarks for del.icio.us on ' . $attrs["DT"] . ":\n\n";
$wp_excerpt = 'Shared bookmarks for del.icio.us on ' . $attrs["DT"] . "...";
}
}
else {
$content = $content . ' - '
. htmlspecialchars($attrs['DESCRIPTION'])
. "\n"
. htmlspecialchars($attrs['EXTENDED'])
. 'Tagged as: ' . htmlspecialchars($attrs['TAG']) . "
\n";
}
}
function endElement($parser, $name)
{
global $content;
if ($name == "POSTS") {
$content = $content . "
";
}
}
$Url = "http://$del_user:$del_password@del.icio.us/api/posts/get?dt=$dt";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 25);
curl_setopt($ch, CURLOPT_PORT, 80);
$data = curl_exec($ch);
$fp = $data;
$errors = curl_error($ch);
curl_close($ch);
if ($errors != '') {
die("CURL Error $errors");
}
$content = "";
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
if (!xml_parse($xml_parser, $data, true)) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
xml_parser_free($xml_parser);
if (substr($content,-10) == "") {
die("\nNo del.icio.us entries found for user " . $del_user . ".\n");
}
# Debugging - Leave commented if you want posts to actually work.
# die("\nKILL\n");
# Build Query
$query = "INSERT INTO $tableposts "
. "(`post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_status`, `comment_status`, `ping_status`, `post_name`, `post_modified`, `post_modified_gmt`, `post_excerpt`) "
. "VALUES "
. "(" . $wp_userid . ", '" . $now . "', '" . $now_gmt . "', '" . addslashes($content) . "', '" . addslashes($wp_posttitle) . "', 'publish', '" . $wp_allowcomments . "', '" . $wp_allowpings . "', '" . $wp_postname . "', '" . $now . "', '" . $now_gmt . "', '" . $wp_excerpt . "');";
# Run Query
$wpdb->query($query);
# Get ID for category
$post_ID = $wpdb->get_var("SELECT ID FROM $tableposts ORDER BY ID DESC LIMIT 1");
# Build category query
$query = "INSERT INTO $tablepost2cat "
. "(`post_id`, `category_id`) "
. "VALUES "
. "('" . $post_ID . "', '" . $wp_catid . "');";
# Run Category Query
$wpdb->query($query);
?>