我不确定自己在做什么错。我使用与PUT
相同的脚本,并且可以正常工作,但是当我使用GET
时,会得到bool(false)
即使我直接在浏览器中访问该网址,我也会得到正确的响应
http://192.168.1.11:189/infinias/ia/Doors?DoorIds=2&username=username&password=password
PHP
$url = 'http://192.168.1.11:189/infinias/ia/Doors';
$data = array('DoorIds' => '2', 'username' => 'username', 'password' => 'password');
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'GET',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
var_dump($result);