break; case 'term': $data = array('term' => StellarData::get_term()); break; case 'myStellar': require_once 'push/apns_lib.php'; $pass_key = intval($_REQUEST['pass_key']); $device_id = intval($_REQUEST['device_id']); $device_type = $_REQUEST['device_type']; $subject = $_REQUEST['subject']; $term = $_REQUEST['term']; if($device_type == 'apple') { if(!APNS_DB::verify_device_id($device_id, $pass_key)) { Throw new Exception("invalid {$pass_key} for {$device_id}"); } } else { Throw new Exception("Device type='${device_type}' not yet supported"); } switch($_REQUEST['action']) { case 'subscribe': StellarData::push_subscribe($subject, $term, $device_id, $device_type); $data = array('success' => True); break; case 'unsubscribe': StellarData::push_unsubscribe($subject, $term, $device_id, $device_type); $data = array('success' => True); break;
public static function create() { $pass_key = intval($_REQUEST['pass_key']); $device_id = intval($_REQUEST['device_id']); $device_type = $_REQUEST['device_type']; if ($device_type != 'apple') { error_log("wrong device type {$device_type} for APNS"); return FALSE; } if (!APNS_DB::verify_device_id($device_id, $pass_key)) { error_log("invalid pass key {$pass_key} for device {$device_id}"); return FALSE; } return new self($device_id, $device_type); }