12. Change Program Data [Keyword /cp]
/cp?pw=xxx&pid=x&v=[flag,days0,days1,[start0,start1,start2,start3],[dur0,dur1,dur2…]]&name=x
Parameters:
• pid: Program index (starting from 0). Acceptable range is -1 to N-1, where N is number of existing programs.
If pid=-1, this is adding a new program; otherwise this is modifying an existing program.
• v: Program data structure. The format is the same as explained in Section 11 above, except the name field, given below.
• name: Program name (url encoded, without quotes).
function sdk_get_program_state()
{
$response = httpQuery($GLOBALS['api_url'].'jp?pw='.$GLOBALS['api_key'], 'GET', $post);
return $response;
}
function sdk_enable_program($pid)
{
$response = httpQuery($GLOBALS['api_url'].'cp?pw='.$GLOBALS['api_key'].'&pid='.($pid).'&en=1', 'GET', $post);
return $response;
}
function sdk_disable_program($pid)
{
$response = httpQuery($GLOBALS['api_url'].'cp?pw='.$GLOBALS['api_key'].'&pid='.($pid).'&en=0', 'GET', $post);
return $response;
}
function sdk_get_pid($program_name)
{
$response = httpQuery($GLOBALS['api_url'].'jp?pw='.$GLOBALS['api_key'], 'GET', $post);
$arr = sdk_json_decode($response);
foreach($arr["pd"] as $item) {
if($item[5] == utf8_encode($program_name)) return $k+1;
$k++;
}
return 0;
}
case 'programstatus':
$program_name = getArg('program_name');
$pid = sdk_get_pid($program_name);
if($pid==0) {
$result = '{"status":false,"msg":"Unknown program ['.$program_name.']"}';
} else {
$response = sdk_get_program_state();
$arr = sdk_json_decode($response);
$result = '{"status": "'.substr(decbin($arr['pd'][$pid-1][0]), -1).'"}';
}
break;
case 'programenable':
$program_name = getArg('program_name');
$pid = sdk_get_pid($program_name);
if($pid==0) {
$result = '{"status":false,"msg":"Unknown program ['.$program_name.']"}';
} else {
$result = sdk_enable_program($pid-1);
}
break;
case 'programdisable':
$program_name = getArg('program_name');
$pid = sdk_get_pid($program_name);
if($pid==0) {
$result = '{"status":false,"msg":"Unknown program ['.$program_name.']"}';
} else {
$result = sdk_disable_program($pid-1);
}
break;
$zone_number = getArg('zone_number');
&action=programenable&program_name=[nom du programme]
&action=programdisable&program_name=[nom du programme]
Utilisateurs parcourant ce forum : Aucun utilisateur inscrit et 28 invité(s)