';
echo '' . PHP_EOL;
echo '' . PHP_EOL;
echo ''."\n";
echo '' . $title . ''."\n";
echo '' . $all->id . ''."\n";
echo ''."\n";
echo ''."\n";
echo '' . $updated . ''."\n";
echo 'Last FM scrobbles from ' . $user_full_name . '.'."\n";
foreach($all[recenttracks][track] as $item) {
// vardump($item['artist']['#text']);
$id = $item[date][uts];
$url = htmlspecialchars($item[url]);
$published = date(DATE_ATOM, $item[date][uts]);
$updated = date(DATE_ATOM, $item[date][uts]);
// Create Content
$post_content = '';
$post_content .= '' . $item['artist']['#text'];
if ($item['album']['#text']) {
$post_content .= ' - ' . $item['album']['#text'];
}
$post_content .= ' - ' . $item['name'] . '
'."\n";
if ($item['image'][2]['#text']) {
$post_content .= '
'."\n";
} else if ($item['image'][3]['#text']) {
$post_content .= '
'."\n";
} else if ($item['image'][1]['#text']) {
$post_content .= '
'."\n";
} else if ($item['image'][0]['#text']) {
$post_content .= '
'."\n";
}
//wrapping the content in CDATA can avoid some XML character set problems.
$post_content = '';
// Create title
$post_title = '';
$post_title .= $item['artist']['#text'];
if ($item['album']['#text']) {
$post_title .= ' - ' . $item['album']['#text'];
}
$post_title .= ' - ' . $item['name'];
// Get only the first line of the title
$post_title = explode("\n", $post_title);
$post_title = $post_title[0];
// Shorten title if it's too long
$max_characters = 255;
if (strlen($post_title)>$max_characters) {
preg_match('/(.{' . $max_characters . '}.*?)\b/', $post_title, $matches);
if ( strlen(rtrim($matches[1])) < strlen($post_title) ) {
$post_title = rtrim($matches[1]) . "...";
}
}
$post_title = htmlspecialchars($post_title);
//Output the item entry
echo ''."\n";
echo ' ' . $post_title . ''."\n";
echo ' ' . $post_content . ''."\n";
echo ' ' . $id . ''."\n";
echo ' ' . $published . ''."\n";
echo ' ' . $updated . ''."\n";
echo ' '."\n";
echo ''."\n";
}
}
echo ''."\n";
// *******************
function create_video_embed($swf_url) {
preg_match('#http://www\.youtube\.com/watch\?v=([A-Za-z0-9\-_]+)#s', $swf_url, $matches);
if (isset($matches[1])) {
$content .= '';
return $content;
} else {
preg_match('#http://w?w?w?.?vimeo.com/moogaloop.swf\?clip_id=([A-Za-z0-9\-_]+)s', $swf_url, $matches);
if (isset($matches[1])) {
return "http://www.vimeo.com/".$matches[1];
} else if (!isset($matches[1])) {
return null;
}
}
}
// *******************
function vardump($var) {
//utility function for debugging
print "
".htmlspecialchars(print_r($var,1));
exit();
}