PHP cURL返回错误505

And*_*res 1 php curl solr

我正在尝试使cURL(或get_file_contents)从以下URL获取内容:

http://localhost:8080/solr/select?q={!geofilt score=distance sfield=geo pt=20.570529,-100.408635 d=20}&sort=score asc&fq=restaurantes&defType=!edismax&wt=json&indent=true&start=0&rows=20&fl=*,score
Run Code Online (Sandbox Code Playgroud)

我从两种方法(cURL和get_file_contents)得到的都是HTTP 505错误.但是,如果我将链接复制并粘贴到像Firefox这样的浏览器上,它可以正常工作......

我尝试的最后一件事是迫使cURL使用不同的HTTP版本,如下所示:

curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
Run Code Online (Sandbox Code Playgroud)

没有运气.

我的代码适用于其他网址,如下所示:

http://localhost:8080/solr/select?q=restaurantes&defType=edismax&qf=category^20.0+name^10.0+keywords^10.0+address^2.0&wt=json&indent=true&start=0&rows=20&fl=*,score
Run Code Online (Sandbox Code Playgroud)

明显的区别在于{,=,}等字符!在URL中.但是,为什么Firefox有效?

And*_*res 9

愚蠢的URL空间......这解决了它.

$qs = str_replace(' ', '+', $qs);
Run Code Online (Sandbox Code Playgroud)

谢谢

更新:看一下PHP的urlencode函数.