Dwarrel schreef:jacqueline schreef:OPgelost
Vertel....

ik heb het volgende gedaan
bij lastfm voor een api key gezorgt daarvoor heb ik daar een account aangemaakt...
en hoe ik dan verder kwam waardoor ik een api key kreeg ... [smilie=blush2.gif] neem me niet voor 12en wat dat stukje ben ik ff kwijt ....
P:S ik weet niet of ik deze code mag of mocht delen met iemand anders
mocht het niet zo zijn : dan mijn exxuus daarvoor
aan de andere kant we zijn er om elkaar te helpen vandaar dat ik deze code die ik van een mede sam gebruiker gekregen heb toch er neer wil zetten
maar hier dan de module nowplaying voor joomla
Code: Selecteer alles
<?php
//////////////////////////////////////////////////////////////////////////////
// Module info //
// Name: SAM Broadcast Now Live //
// Description: It shows the song thats now playing on SAMserver //
// author: Paules //
// Date created: 22-11-2010 //
// copyright: Copyright (C) 2010 Paules.eu //
// Licence: http://www.paules.eu //
// Email: webmaster@paules.eu //
// Mod version: 1.0 //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Edit information below here //
//////////////////////////////////////////////////////////////////////////////
$SamMysqlhost = "mijn ip van sam waar ik mee draai"; // put here the SAMmysql host Like--> $SamMysqlhost = "mijnhost.nl";
$SamMysqlport = "3306"; // put here the SAMmysql port Like--> $SamMysqlport = "3306";
$SamMysqluser = "...."; // put here the SAMmysql user Like--> $SamMysqluser = "root";
$SamMysqlpass = "...."; // put here the SAMmysql pass Like--> $SamMysqlpass = "12345";
$SamMysqldata = "samdb"; // put here the SAMmysql database Like--> $SamMysqldata = "SAMDB";
$SamColorText = "#FFFFFF"; // put here the color of some output text like Artis Like--> $SamColorText = "#611f1d";
//////////////////////////////////////////////////////////////////////////////
// Lastfm data //
//////////////////////////////////////////////////////////////////////////////
$LastfmURL = "http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=";
$LastfmAPIkey = "HIER KOMT JE API KEY"; // the api key we need to contact last.fm
//////////////////////////////////////////////////////////////////////////////
// Don't edit any code below here or it will not work //
//////////////////////////////////////////////////////////////////////////////
// Get All Data We Need From Server //
//////////////////////////////////////////////////////////////////////////////
//Only the AJAX script may call the code below
if ($IdoCheck != "yes")
{
//Start new mysql connection
$SAMconnectmysql = mysql_connect($SamMysqlhost, $SamMysqluser, $SamMysqlpass);
if (!$SAMconnectmysql)
{
die("Could not connect: " . mysql_error());
}
//Select mysql Database
$SAMconnectmysqldb = mysql_select_db($SamMysqldata, $SAMconnectmysql);
if (!$SAMconnectmysqldb)
{
die("Could not connect: " . mysql_error());
}
//getting all info mysql info we need
$SAMlastplayed0 = mysql_query("SELECT * FROM historylist ORDER BY ID DESC LIMIT 0 , 1");
//fetch all mysql info we need
$SAMNowplaying_result0 = mysql_fetch_array($SAMlastplayed0);
//Timecheck ---- $songtimeleft1 = < 0 if the song is history. other the song is now playing
$TimeTrackStarted = strtotime($SAMNowplaying_result0["date_played"]);
$ClientTimeNow = time()+3600;
$Songtimeleft = $TimeTrackStarted+round($SAMNowplaying_result0["duration"]/1000)-$ClientTimeNow;
//get the tracktime
$timeplaying = date('i:s', $Songtimeleft);
//getting all fetched data we need
$SAMlastplayed0SONGTIME = $SAMNowplaying_result0["duration"]/1000;
$SAMlastplayed0DATE = $SAMNowplaying_result0["date_played"];
$SAMlastplayed0ARTIST = $SAMNowplaying_result0["artist"];
$SAMlastplayed0TITLE = $SAMNowplaying_result0["title"];
//check if the song has a songArtist - if not make songArtist the text below
if ($SAMlastplayed0ARTIST == '')
{
$SAMlastplayed0ARTIST = 'Geen Artiest';
}
//close the mysql connection
if ($SAMconnectmysql)
{
mysql_close($SAMconnectmysql);
}
//////////////////////////////////////////////////////////////////////////////
// Make a output for the joomla //
//////////////////////////////////////////////////////////////////////////////
if ($Songtimeleft < "0")
{ //this will be the output if there is no SAMserver Playing
echo '<img src="modules/mod_SamNowLive/pics/offline.jpg" width="130" height="50" /></BR>';
}
else if ($Songtimeleft > "0")
{ //this will be the output to is everything is correct
echo "<font size='2' color='#611f1d'>Artiest:</font> $SAMlastplayed0ARTIST <br> <font size='2' color='#611f1d'>Nummer:</font> $SAMlastplayed0TITLE <br><br> <center><font size='4' color='#611f1d'>$timeplaying</font></center>";
}
else
{ //this will be the output when AJAX is crashed or the songtime is 0
echo "Loading.....";
}
}
?>
Dat dan geupt in de module map "nowplaying" includes ( deze code sla je op als getdata )
Alleen wat bij mij dan NIET te zien is : das het stukje dat onder de covers komt te staan : de titel en artiest
Maar daar ga ik nog mee puzzelen
Deze code heb ik van een sam gebruiker
bedankt nog
edit : dit stukje had in gedeelte Joomla moeten staan ... maar maby dat het ook op deze manier gebruikt kan worden voor de website ( i dont verder know :$ )