$value) { if($key!='sig'){ $params .= "$key=$value"; } } return md5($params . $secret_key); } if(isset($_REQUEST['app'])){ if($_REQUEST['app']=='1'){ $VK = new vkapi('2655067','iwF1wOKlvMSZE7NfKHzM'); //tanks define('ok_secret','D4C879AE2F18E1A2F100B13B'); define('ok_public','CBANBCFBABABABABA'); define('mm_secret','f49376e4dc8e26a47ea7ea5f32e445b0'); define('mm_id','649796'); }else if($_REQUEST['app']=='2'){ $VK = new vkapi('3988951','fl3eQGyzKNCJOEF15GNW'); //robots define('ok_secret','98779637FBA5601244FF6FEF'); define('ok_public','CBAPKNBDEBABABABA'); define('mm_secret','82818d49aa4515ec784efd3b7c06976b'); define('mm_id','714771'); }else{ echo 'app not exists'; exit; } }else{ echo 'app is not set'; exit; } if(isset($_REQUEST['method'])){ if(isset($_REQUEST['network'])){ if($_REQUEST['network']=='vk'){ if($_REQUEST['method']=='setLevel'){ $otvet = $VK->api('secure.addAppEvent', array('user_id'=>$_REQUEST['uid'], 'activity_id'=>1, 'value'=>$_REQUEST['level'])); $otvet=(object)$otvet; if($otvet->response=='1'){ echo '1'; }else{ echo json_encode($otvet); } }else if($_REQUEST['method']=='setScore'){ $otvet = $VK->api('secure.addAppEvent', array('user_id'=>$_REQUEST['uid'], 'activity_id'=>2, 'value'=>$_REQUEST['score'])); if(!isset($_REQUEST['score'])){ exit('score is missing'); } $otvet=(object)$otvet; if($otvet->response=='1'){ echo '1'; }else{ echo json_encode($otvet); } }else if($_REQUEST['method']=='setMission'){ if(!isset($_REQUEST['mission_id'])){ exit('mission_id is missing'); } $otvet = $VK->api('secure.addAppEvent', array('user_id'=>$_REQUEST['uid'], 'activity_id'=>$_REQUEST['mission_id'])); $otvet=(object)$otvet; if($otvet->response=='1'){ echo '1'; }else{ echo json_encode($otvet); } }else if($_REQUEST['method']=='sendNotification'){ $otvet = $VK->api('secure.sendNotification', array('user_id'=>$_REQUEST['uid'], 'message'=>$_REQUEST['msg'])); $otvet=(object)$otvet; //{"response":"40967845"} if( $otvet->response==$_REQUEST['uid'] ){ echo '1'; }else{ echo json_encode($otvet); } }else if($_REQUEST['method']=='setCounter'){ $otvet = $VK->api('secure.setCounter', array('user_id'=>$_REQUEST['uid'], 'counter'=>$_REQUEST['count'])); $otvet=(object)$otvet; if($otvet->response=='1'){ echo '1'; }else{ echo json_encode($otvet); } }else if($_REQUEST['method']=='clearCounter'){ $otvet = $VK->api('secure.setCounter', array('user_id'=>$_REQUEST['uid'], 'counter'=>0)); $otvet=(object)$otvet; if($otvet->response=='1'){ echo '1'; }else{ echo json_encode($otvet); } }else{ echo 'method not exists'; exit; } }else if($_REQUEST['network']=='ok'){ if($_REQUEST['method']=='sendNotification'){ $data = array( 'method'=>'notifications.sendSimple', 'application_key'=>ok_public, 'uid'=>$_REQUEST['uid'], 'text'=>$_REQUEST['msg'] ); $sig=sign_server_server($data, ok_secret); $data['sig']=$sig; $req=http_build_query($data); $r=file_get_contents("http://api.odnoklassniki.ru/fb.do?".$req); if($r=='true'){ echo '1'; //echo $r; }else{ echo $r; } }else{ echo 'method not exists'; exit; } }else if($_REQUEST['network']=='mail'){ if($_REQUEST['method']=='sendNotification'){ $data = array( 'method'=>'notifications.send', 'app_id'=>mm_id, 'text'=>$_REQUEST['msg'], 'uids'=>$_REQUEST['uid'], 'secure'=>'1' ); $sig=sign_server_server($data, mm_secret); $data['sig']=$sig; $req=http_build_query($data); $r=file_get_contents("http://www.appsmail.ru/platform/api?".$req); //echo $otvet; //$otvet=$otvet; //$otvet=(array)$r; if($r=='["'.$_REQUEST['uid'].'"]'){ echo '1'; }else{ echo $r; } }else{ echo 'method not exists'; exit; } }else{ echo 'network not exists'; exit; } }else{ echo 'network is not set'; exit; } }else{ echo 'method is not set'; } ?>