function sendAndroidUnicast() { try { $unicast = new AndroidUnicast(); $unicast->setAppMasterSecret($this->appMasterSecret); $unicast->setPredefinedKeyValue("appkey", $this->appkey); $unicast->setPredefinedKeyValue("timestamp", $this->timestamp); // Set your device tokens here $unicast->setPredefinedKeyValue("device_tokens", "xx"); $unicast->setPredefinedKeyValue("ticker", "Android unicast ticker"); $unicast->setPredefinedKeyValue("title", "Android unicast title"); $unicast->setPredefinedKeyValue("text", "Android unicast text"); $unicast->setPredefinedKeyValue("after_open", "go_app"); // Set 'production_mode' to 'false' if it's a test device. // For how to register a test device, please see the developer doc. $unicast->setPredefinedKeyValue("production_mode", "true"); // Set extra fields $unicast->setExtraField("test", "helloworld"); print "Sending unicast notification, please wait...\r\n"; $unicast->send(); print "Sent SUCCESS\r\n"; } catch (Exception $e) { print "Caught exception: " . $e->getMessage(); } }
function sendAndroidUnicast($arr) { // $this->sendAndroidBroadcast($arr); try { $unicast = new AndroidUnicast(); $unicast->setAppMasterSecret($this->appMasterSecret); $unicast->setPredefinedKeyValue("appkey", $this->appkey); $unicast->setPredefinedKeyValue("timestamp", $this->timestamp); // Set your device tokens here $unicast->setPredefinedKeyValue("device_tokens", $arr['device_tokens']); $unicast->setPredefinedKeyValue("ticker", $arr['ticker']); $unicast->setPredefinedKeyValue("title", $arr['title']); $unicast->setPredefinedKeyValue("text", $arr['text']); $unicast->setPredefinedKeyValue("after_open", "go_app"); $unicast->setPredefinedKeyValue("description", $arr['text']); // Set 'production_mode' to 'false' if it's a test device. // For how to register a test device, please see the developer doc. $unicast->setPredefinedKeyValue("production_mode", "true"); // Set extra fields $unicast->setExtraField("code", $arr['code'] ? $arr['code'] : 0); // print("Sending unicast notification, please wait...\r\n"); $unicast->send(); // print("Sent SUCCESS\r\n"); return true; } catch (Exception $e) { return false; print "Caught exception: " . $e->getMessage(); die; } }
public function alipay() { $success = 'success'; $fail = 'fail'; $out_trade_no = ggp('out_trade_no'); $trade_status = ggp('trade_status'); $trade_status_array = array('WAIT_SELLER_SEND_GOODS', 'TRADE_FINISHED', 'TRADE_SUCCESS'); if (ggp('op') == 'callback') { if (in_array($trade_status, $trade_status_array)) { $order = M('order')->where("order_id='{$out_trade_no}' or order_sn='{$out_trade_no}'")->find(); $this->mySuccess('msg_common_add_success', $this->my['uid'] ? "index.php?m=home&a=order" : "index.php?m=order&vieworder&order_id={$order['order_id']}"); } $this->myError('error_common_error', U('home/order')); } else { if (ggp('op') == 'notify') { if ($trade_status == 'WAIT_BUYER_PAY') { exit($success); } else { if (in_array($trade_status, $trade_status_array)) { if (count(explode(',', $out_trade_no)) > 1) { $wheresql = "order_id in({$out_trade_no})"; } else { $wheresql = "(order_sn='{$out_trade_no}' or order_id='{$out_trade_no}')"; } $wheresql .= " and state=6"; M('order')->where($wheresql)->save(array('state' => '2')); $order = M('order')->where($wheresql)->select(); Vendor('notification.android.AndroidUnicast'); foreach ($order as $key => $val) { $msg = "您有新的订单!订单号为:{$val['order_sn']}"; $store = M("store")->where("sid={$val['store_id']}")->find(); mobile_sms($store['mobile'], $msg, $this->setting); if ($store['device_token']) { $unicast = new AndroidUnicast($msg, $msg, $msg, $store['device_token'], 1, "{order_id:{$val['order_id']}}"); $unicast->send(); } } exit($success); } else { if ($trade_status == 'WAIT_BUYER_CONFIRM_GOODS') { //卖家已经发货等待买家确认收货 exit($success); } } } exit($fail); } } }