V
V
Vladimir2021-06-21 01:57:08
PHP
Vladimir, 2021-06-21 01:57:08

How to make such a post request using file_get_contents in php?

Actually such a Post request

curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "OFF" "http://{openHAB_IP}:8080/rest/items/My_Item"

Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
none7, 2021-06-21
@none7

file_get_contents('http://{openHAB_IP}:8080/rest/items/My_Item', false, stream_context_create(array('http' => array(
    'method' => 'POST',
    'header' => 'Content-Type: text/plain\r\nAccept: application/json\r\n',
    'content' => 'OFF'
))));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question