[php]
// do functions: get from db, get from api
$filterTag = “#SMNT”;

$mysqli = new mysqli(“mysql.shootmenow.me”, “mikaelletang”, “virtuonz”, “shootmenow_me”);
if ($mysqli->connect_errno) {
echo “Echec lors de la connexion à MySQL : ” . $mysqli->connect_error;
}
$query = “SELECT name from bambuser_user”;
$users = array();
if ($result = $mysqli->query($query)) {
while ($row = $result->fetch_array()) {
$users[] = $row[‘name’];
}
/* free result set */
$result->close();
}
$apiUrl = “http://api.bambuser.com/broadcast.json?api_key=aa5d8ff65836e9d110a266f8f4cbe23b&username=”;
$videos = array();
foreach($users as $bambuser) {
$url = $apiUrl.$bambuser;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$json = curl_exec($ch);
curl_close($ch);
$result = json_decode($json);
$videos[$bambuser] = $result->result;
}
//var_dump($videos);
$videoIframes = array();
foreach($videos as $user => $userVideos) {
foreach($userVideos as $video) {
$videoName =$video->title;
$videoId = $video->vid;
$words = explode(” “, $videoName);
$tags = array();
foreach($words as $word) {
if (strpos($word, ‘#’) === 0) {
$tags[] = $word;
}
}

if (!in_array($filterTag, $tags)){continue;}
//$tagPattern = “/(#\[^ \]*)/”;
//var_dump($tagPattern);
//echo “%”.$videoName.”%”;
//preg_match_all($tagPattern, $videoName, $matches);
//$tags = (isset($matches[1])) ? $matches[1] : array();
//var_dump($matches);

//echo “[h3]”.$user.”: “.$videoName.”(“.$videoId.”)”.implode(‘,’, $tags).”[/h3]”;
echo “[h2]From “.$user.”: “.$videoName.”[/h2]”;
echo “[h3]”.implode(‘,’, $tags).”[/h3]”;
echo ‘[iframe src=”http://embed.bambuser.com/broadcast/’.$videoId.'” frameborder=”0″ width=”460″ height=”396″][/iframe]’;

//$videoIframes[] = $video->vid;
}
}
// get all users
// get all theirs videos
// filter those with SMN #tag
// extract tags
// create categories
//

[/php]