が、私はそれだけでこれを読むために別の方法を見つけるいけない、私はちょうど$の映画や本をharcodedと私は、このエラーメッセージが出ます:エラー:のfile_get_contents私はXMLを読み取る必要がある
を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
私はこのエラーが発生し、これは私のコードです、エラーは、誰かが助けることができる、どのようにそれを修正するのですか?期待どおりurlencode() URLパラメータ(すなわち$movie
)は、それが動作するはず
$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);
}
私はこれを試してみました:$データ=ののfile_get_contents(でurlencode( 'http://news.google.com.mx/news?hl=es&gl=mx&q='.$cine.'&bav=on.2、 cf.osb&um = 1&ie = UTF-8&output = rss ')); – bentham
にはそのようなファイルやディレクトリはありません。特別な文字やスペースを含むことがあるクエリ文字列( '?'の後ろ)に '$ movie'やその他のパラメータが渡されます。 – drew010
ありがとうございました – bentham