I have put together little utility for reading youtube video tags. http://ift.tt/1Kg80CS
<?php
header("Content-Type: application/json");
error_reporting(E_ERROR | E_PARSE);
$_POST['fn']='http://ift.tt/1Kg80CU';
if(isset($_POST['fn']) && $_POST['fn'] != ''){
$url = htmlentities($_POST['fn']);
$page_content = file_get_contents('http://ift.tt/1Kg80CU');
$dom_obj = new DOMDocument();
if($dom_obj->loadHTML($page_content)){
$dom_obj->loadHTML($page_content);
$meta_val = '';
foreach($dom_obj->getElementsByTagName('meta') as $meta) {
if($meta->getAttribute('property')=='og:video:tag'){
$meta_val = $meta_val.','.$meta->getAttribute('content');
}
}
echo substr($meta_val,1);
}
else{
echo "Invalid Url!";
}
}
else{
echo "Empty Url!";
}
?>
It works for ASCI characters but UTF characters show unreadable. I can't find the problem.
Aucun commentaire:
Enregistrer un commentaire