ブラウザで次のクエリを実行すると、次のようになります。
http://127.0.0.1:8096/solr/select/?q=june 17&start=0&rows=8&indent=on&hl=on&hl.fl=Data&wt=json
結果が出ます。問題はありません。6月と17の間にスペースがあることに注意してください
ただし、PHPでそのクエリを受け取った場合、つまり$ q =June17を使用します
$url="http://127.0.0.1:8096/solr/select/?q=$q&start=0&rows=8&indent=on&hl=on&hl.fl=Data&wt=json";
$json_O=json_decode(file_get_contents($url),true);
この後、firebugに次のように表示されます。
<b>Warning</b>: file_get_contents(http://127.0.0.1:8096/solr/select/?q=june 17&start=0&rows=8&indent=on&hl=on&hl.fl=Data&wt=json) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 505 HTTP Version Not Supported
ただし、クエリワードの間にスペースがない場合(つまり、単一のワードの場合)、すべてが完璧であることに注意してください。
file_get_contents()と比較して、ブラウザーでまったく同じクエリを発行すると、なぜ正常に機能するのですか。任意の解決策をいただければ幸いです。