function getChannel($username) { $text = file_get_the_contents('http://api.ustream.tv/json/channel/' . $username . '/listAllChannels?key=BFB059F029979EED85D4E9C36B1A18D3'); $phpObj = json_decode($text, true); if ($phpObj['error']) { return NULL; } foreach ($phpObj['results'] as $res) { return $res['id']; } }
function getChannel($username) { $text = file_get_the_contents('http://api.ustream.tv/json/channel/' . $username . '/listAllChannels?key=BFB059F029979EED85D4E9C36B1A18D3'); $phpObj = json_decode($text, true); foreach ($phpObj['results'] as $res) { if ($res['status'] == 'live') { //echo($res['id']); return $res['id']; } } //no live streams detected so just return the first streamid return $phpObj['results']['0']['id']; }
function art_query($artist, $album) { $album = preg_replace('!\\(.+\\)!', '', $album); $theq = "{$artist}, {$album}"; $query = urlencode($theq); $amazonKey = getSystemSetting("amazonid"); $Operation = "ItemSearch"; $Version = "2007-07-16"; $ResponseGroup = "ItemAttributes,Images"; $request = "http://ecs.amazonaws.com/onca/xml" . "?Service=AWSECommerceService" . "&AWSAccessKeyId=" . $amazonKey . "&Operation=" . $Operation . "&Version=" . $Version . "&SearchIndex=Music" . "&Keywords=" . $query . "&ResponseGroup=" . $ResponseGroup; logger($request . "\n"); $response = file_get_the_contents($request); $parsed_xml = simplexml_load_string($response); if (isset($parsed_xml->OperationRequest->Errors->Error) || isset($parsed_xml->Items->Request->Errors)) { logger("Artwork lookup failed"); return null; } else { return $parsed_xml->Items->Item[0]->MediumImage->URL; } }