0
这个问题相当微不足道,但是尽管搜索并尝试了不同的方法,我无法实现它的工作。带参数的PHP调用
,我有以下内容在我的action.php的
<?php
function sendCommand($item, $data)
{
$url = "https://host/rest/items/" . $item;
$options = array(
'http' => array(
'header' => "Content-type: text/plain\r\n",
'method' => 'POST',
'content' => $data //http_build_query($data),
),
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
return $result;
}
?>
这是我的html页面
<form action="action.php?item=CancelParty&data=ON" method="post" align="center" class="form-inline" role="form">
<button type="submit" class="btn btn-warning btn-fill">Volume down</button>
</form>
的一部分,但我的请求没有被处理。我错过了什么?我通常不会做任何PHP或REST调用,对于webdeveloper这一次一定是很容易的,我认为:)
如果是整PHP文件,该功能从未被使用过。它已被声明,但不会在任何地方调用。 – junkfoodjunkie