我一直在尝试从我在服务器上创建的PHP页面访问这个特定的REST服务.我将问题缩小到这两行.所以我的PHP页面如下所示:
<?PHP
$response = file_get_contents("https://maps.co.weber.ut.us/arcgis/rest/services/SDE_composite_locator/GeocodeServer/findAddressCandidates?Street=&SingleLine=3042+N+1050+W&outFields=*&outSR=102100&searchExtent=&f=json");
echo $response; ?>
解决方法:
http://php.net/manual/en/migration56.openssl.php
一篇官方文档,描述了在PHP 5.6中打开ssl所做的更改
从这里我学到了另一个我应该设置为false的参数:“verify_peer_name”=> false
Note: This has very significant security implications. disabling verification potentially permits a 07001 to use an invalid certificate to eavesdrop on the requests. While it may be useful to do this in local development, other approaches should be used in production.
所以我的工作代码如下所示:
<?PHP
$arrContextOptions=array(
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
$response = file_get_contents("https://maps.co.weber.ut.us/arcgis/rest/services/SDE_composite_locator/GeocodeServer/findAddressCandidates?Street=&SingleLine=3042+N+1050+W&outFields=*&outSR=102100&searchExtent=&f=json", false, stream_context_create($arrContextOptions));
echo $response; ?>