소스 검색

add umeng

liax 9 년 전
부모
커밋
d00cda2044
2개의 변경된 파일179개의 추가작업 그리고 17개의 파일을 삭제
  1. 129 0
      helper/umeng.php
  2. 50 17
      mobile/control/test.php

+ 129 - 0
helper/umeng.php

@@ -0,0 +1,129 @@
+<?php
+
+/**
+ * Created by PhpStorm.
+ * User: dell
+ * Date: 2016/4/15
+ * Time: 16:27
+ */
+class msg_type extends SplEnum
+{
+    const __default = self::unicast;
+    const unicast = "unicast";
+    const listcast = "listcast";
+    const filecast = "filecast";
+    const broadcast = "broadcast";
+    const groupcast = "groupcast";
+    const customizedcast = "customizedcast";
+    const alias = "alias";
+    const file_id = "file_id";
+}
+
+class display_type extends SplEnum
+{
+    const __default = self::notification;
+    const notification = "notification";
+    const message = "message";
+}
+
+
+class upush
+{
+    const PUSH_URL = "http://msg.umeng.com/api/send?sign=";
+    const APPKEY = "5631efd4e0f55a8770000027";
+
+    public function __construct()
+    {
+    }
+
+    public function http_post_data($url, $data_string)
+    {
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_POST, 1);
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
+        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
+                'Content-Type: application/json; charset=utf-8',
+                'Content-Length: ' . strlen($data_string))
+        );
+        ob_start();
+        curl_exec($ch);
+        $return_content = ob_get_contents();
+        ob_end_clean();
+        $return_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+        return array($return_code, $return_content);
+    }
+
+    // android 打包
+    private function android_pack()
+    {
+        $pack = array();
+        $pack['appkey'] = self::APPKEY;
+        $pack['timestamp'] = time();
+        $pack['type'] = msg_type::unicast;
+        $pack['device_tokens'] = "Aj9AympPsCha5zmPhrV0DbnOZJYF0pqKY5jdKvFy_Hbu";
+        $pack['alias_type'] = "";
+        $pack['alias'] = "";
+        $pack['file_id'] = "";
+        $pack['filter'] = "";
+        $payload = array();
+        $body = array();
+        $body['ticker'] = "通知栏提示文字";
+        $body['title'] = "通知图标";
+        $body['text'] = "通知文字描述";
+        $body['icon'] = "";
+        $body['largeIcon'] = "";
+        $body['img'] = "";
+        $body['sound'] = "";
+        $body['builder_id'] = "";
+        $body['play_vibrate'] = "true";
+        $body['play_lights'] = "true";
+        $body['play_sound'] = "true";
+        $body['after_open'] = "go_app";
+        $body['url'] = "";
+        $body['activity'] = "";
+        $body['custom'] = "";
+
+        $extra = array();
+        $extra['key1'] = "key1";
+        $extra['key1'] = "key2";
+        $extra['key1'] = "key3";
+
+        $payload['display_type'] = display_type::message;
+        $payload['body'] = $body;
+        $payload['extra'] = $extra;
+        $pack['payload'] = $payload;
+
+        $policy = array();
+        $policy['start_time'] = "";
+        $policy['expire_time'] = "";
+        $policy['max_send_num'] = "";
+        $policy['out_biz_no'] = "10001";
+
+        $pack['policy'] = $policy;
+        $pack['production_mode'] = "false";
+//        $pack['description'] = $this->description;
+//        $pack['thirdparty_id'] = $this->thirdparty_id;
+
+        return $pack;
+    }
+
+    // ios 打包
+    private function ios_pack()
+    {
+
+    }
+
+    // android 推送
+    public function android_push()
+    {
+        return $this->http_post_data(self::PUSH_URL, self::android_pack());
+    }
+
+    // ios 推送
+    public function ios_push()
+    {
+
+    }
+
+}

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 50 - 17
mobile/control/test.php