function analyze_radiomedia($id) { global $errormsg; $url = 'http://www.onsen.ag/data/api/getMovieInfo/' . $id . '?callback=callback'; // print $url."\n"; $json = file_get_html_with_retry($url); if ($json === false) { print "Onsen Meta data Download Failed \n"; print "id : {$id} \n"; print "url {$url} \n"; print $json . " \n"; return $json; } // print $json."\n"; preg_match('/callback\\((.+)\\)/', $json, $json_matchs); // var_dump($json_matchs); $radioinfo = json_decode($json_matchs[1], $assoc = true); // var_dump($radioinfo); if (is_null($radioinfo)) { print "Onsen Meta data Json Decode Failed \n"; print "id : {$id} \n"; print "url {$url} \n"; print $json . " \n"; return false; } if (!array_key_exists('moviePath', $radioinfo)) { print "Onsen Meta data has no moviePath \n"; print "id : {$id} \n"; print "url {$url} \n"; print $json . " \n"; } return $radioinfo; }
if ($contents !== false) { curl_close($ch); break; } $errno = curl_errno($ch); $errormsg = curl_error($ch); print $timeoutsec; curl_close($ch); } if ($loopcount === $retrytimes) { $error_message = curl_strerror($errno); print 'http connection error : ' . $error_message . ' url : ' . $url . "\n"; } return $contents; } $html = file_get_html_with_retry($onsentopurl); if ($html == false) { print "Onsen Top Page download Failed.\n"; die; } $html = mb_convert_encoding($html, 'HTML-ENTITIES', 'ASCII, JIS, UTF-8, EUC-JP, SJIS'); #mb_convert_variables("UTF-8",'auto',$html ); $domDocument = new DOMDocument(); libxml_use_internal_errors(true); $domDocument->loadHTML($html); libxml_clear_errors(); $xmlString = $domDocument->saveXML(); $xmlObject = simplexml_load_string($xmlString); $array = json_decode(json_encode($xmlObject), true); $programarray = $array['body']['div']['div'][0]['div']['div'][0]['div']['div']["section"][1]["div"][1]["ul"]["li"]; #var_dump($programarray);