Shoutcast 脚本不适用于带有撇号的名称

Shoutcast Script Does Not Work with Names that Have an Apostrophe

请帮帮我,我不知道该怎么办。已尝试 urlencode 但无效 UTF-8 不起作用。我需要脚本可以读取撇号以显示图像,但无事可做我不是程序员,现在我需要你的帮助来解决这个问题。

<?php
$cover_d = 'http://metalrockpopradio.caramania.com/blackblack.gif';  
$sc_url_ip = "69.175.13.131"; 
$sc_url_port = "8050"; 

function getNowPlaying($sc_url_ip,$sc_url_port) {

  $open = fsockopen($sc_url_ip,$sc_url_port,$errno,$errstr,'.5'); 
  if ($open) { 
    fputs($open,"GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n"); 
    stream_set_timeout($open,'1');
    $read = fread($open,200);
    $text = explode(",",$read);
    if($text[6] == '' || $text[6] == '</body></html>') { 
      $msg = ' live stream  '; 
    } else { 
      $msg = $text[6]; 
    }
    $text = $msg; 
  } else {  
    return false; 
  } 
  fclose($open);

  return $text; 
}

$current_song = getNowPlaying($sc_url_ip,$sc_url_port);
$current_song = iconv('ISO-8859-1', 'UTF-8', $current_song);
$singinfo = explode(" - ",$current_song);

$artist = urlencode($singinfo[0]);
$titel = urlencode(strip_tags($singinfo[1]));

$imgurl = @file_get_contents("http://api.depubliekeomroep.nl /anp/albumart.php?artiest=".$artist."&titel=".$titel."&size=extralarge");

if ($imgurl != "") {
  print "<img src=\"" . $imgurl . "\">";
} else { 
  print "<img src=\"" . $cover_d . "\">";
}
?>

我们说的是 ASCII 39 是吗?我的意思是这甚至有效...

<?php

$artist = "Tom Petty";
$title = "I won't back down";
$uri = "http://api.depubliekeomroep.nl/anp/albumart.php?artiest={$artist}&titel={$title}&size=extralarge";

var_dump(file_get_contents($uri));

'https://lastfm-img2.akamaized.net/i/u/300x300/05600d9c77a9288add89fac53d3482e7.png' (length=82)

也许提供一个给您带来麻烦的实际字符串的示例?

虽然以上对我有用,但它可能取决于底层包装器。

最佳做法是:

$title = urlencode("I won't back down");