我需要读取一个 xml,我没有找到另一种读取它的方法,我只是对 $movie 和这个进行了编码,然后我收到了这个错误消息:
Warning: file_get_contents(http://news.google.com.mx/news?hl=es&gl=mx&q=harry potter&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.,cf.osb&um=1&ie=UTF-8&output=rss) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request
我收到此错误,这是我的代码,错误在 url 中有人可以帮忙,如何解决?
$url =
$data = file_get_contents('http://news.google.com.mx/news?hl=es&gl=mx&q='.$movie.'&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.,cf.osb&um=1&ie=UTF-8&output=rss');
$xml = new SimpleXMLElement($data);
$channel = array();
$channel['title'] = $xml->channel->title;
foreach ($xml->channel->item as $item)
{
//echo $article['title'] = $item->title;
//echo $article['link'] = $item->link;
echo $article['pubDate'] = $item->pubDate;
echo $article['description'] = (string) trim($item->description);
}