文件名称:php 数据POST
文件大小:3KB
文件格式:PHP
更新时间:2018-06-05 15:12:10
POST
public function air_switch( $is_on) { $headers = array( 'POST /v1.0/device/21288/sensor/37498/datapoints HTTP/1.1', 'Host: api.yeelink.net', 'Accept: */*', 'U-ApiKey: ea012909bbf86a2f927b9d2e8a0f58fd', ); $switch = '{"value":' . $is_on . '}'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'api.yeelink.net/v1.0/device/21288/sensor/37498/datapoints'); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $switch); $data = curl_exec($curl); curl_close($curl); }