├── .gitignore ├── .travis.yml ├── src ├── getui │ ├── igetui │ │ ├── IGt.ListMessage.php │ │ ├── IGt.SingleMessage.php │ │ ├── template │ │ │ ├── IGt.APNTemplate.php │ │ │ ├── notify │ │ │ │ └── IGt.Notify.php │ │ │ ├── IGt.TransmissionTemplate.php │ │ │ ├── IGt.LinkTemplate.php │ │ │ ├── IGt.NotificationTemplate.php │ │ │ ├── IGt.BaseTemplate.php │ │ │ └── IGt.NotyPopLoadTemplate.php │ │ ├── utils │ │ │ ├── LogUtils.php │ │ │ ├── LangUtils.php │ │ │ ├── AppConditions.php │ │ │ ├── ApiUrlRespectUtils.php │ │ │ ├── GTConfig.php │ │ │ ├── HttpManager.php │ │ │ └── ApnsUtils.php │ │ ├── IGt.Target.php │ │ ├── IGt.TagMessage.php │ │ ├── IGt.Message.php │ │ ├── IGt.MultiMedia.php │ │ ├── IGt.AppMessage.php │ │ ├── IGt.APNPayload.php │ │ └── IGt.Req.last.php │ ├── Parser.php │ ├── protobuf │ │ ├── type │ │ │ ├── pb_scalar.php │ │ │ ├── pb_bool.php │ │ │ ├── pb_enum.php │ │ │ ├── pb_int.php │ │ │ ├── pb_signed_int.php │ │ │ ├── pb_bytes.php │ │ │ └── pb_string.php │ │ ├── reader │ │ │ ├── pb_input_reader.php │ │ │ └── pb_input_string_reader.php │ │ ├── encoding │ │ │ └── pb_base128.php │ │ └── pb_message.php │ ├── demo-pushinfo.php │ ├── exception │ │ └── RequestException.php │ ├── IGt.Batch.php │ ├── alias_demo.php │ ├── demo.php │ └── IGt.Push.php ├── PushInterface.php ├── Facade │ └── GeTui.php ├── Exceptions │ └── PushException.php ├── Message.php ├── GeTuiServiceProvider.php ├── config │ └── getui.php └── GeTuiService.php ├── composer.json ├── tests └── PushTest.php ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor/ 2 | /.idea/ 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | php: 3 | - 7.0 4 | - 7.1 5 | before_script: 6 | - composer install 7 | 8 | script: 9 | - vendor/bin/phpunit tests/PushTest -------------------------------------------------------------------------------- /src/getui/igetui/IGt.ListMessage.php: -------------------------------------------------------------------------------- 1 | parse('./performance.proto'); 12 | ?> -------------------------------------------------------------------------------- /src/PushInterface.php: -------------------------------------------------------------------------------- 1 | value = $value; 13 | } 14 | 15 | /** 16 | * Get the scalar value 17 | */ 18 | public function get_value() 19 | { 20 | return $this->value; 21 | } 22 | } 23 | ?> 24 | -------------------------------------------------------------------------------- /src/getui/protobuf/type/pb_bool.php: -------------------------------------------------------------------------------- 1 | value = $this->reader->next(); 17 | $this->value = ($this->value != 0) ? 1 : 0; 18 | } 19 | 20 | } 21 | ?> 22 | -------------------------------------------------------------------------------- /src/getui/demo-pushinfo.php: -------------------------------------------------------------------------------- 1 |
"); 14 | } 15 | 16 | ?> 17 | -------------------------------------------------------------------------------- /src/getui/exception/RequestException.php: -------------------------------------------------------------------------------- 1 | requestId = $requestId; 16 | } 17 | public function getRequestId() 18 | { 19 | return $this->requestId; 20 | } 21 | } -------------------------------------------------------------------------------- /src/getui/igetui/IGt.Target.php: -------------------------------------------------------------------------------- 1 | appId; 19 | } 20 | function set_appId($appId) 21 | { 22 | return $this->appId = $appId; 23 | } 24 | function get_clientId() 25 | { 26 | return $this->clientId; 27 | } 28 | function set_clientId($clientId) 29 | { 30 | return $this->clientId = $clientId; 31 | } 32 | function set_alias($alias) 33 | { 34 | return $this->alias = $alias; 35 | } 36 | function get_alias() 37 | { 38 | return $this->alias; 39 | } 40 | } -------------------------------------------------------------------------------- /src/getui/protobuf/type/pb_enum.php: -------------------------------------------------------------------------------- 1 | value = $this->reader->next(); 17 | } 18 | 19 | /** 20 | * Serializes type 21 | */ 22 | public function SerializeToString($rec=-1) 23 | { 24 | $string = ''; 25 | 26 | if ($rec > -1) 27 | { 28 | $string .= $this->base128->set_value($rec << 3 | $this->wired_type); 29 | } 30 | 31 | $value = $this->base128->set_value($this->value); 32 | $string .= $value; 33 | 34 | return $string; 35 | } 36 | } 37 | ?> 38 | -------------------------------------------------------------------------------- /src/getui/protobuf/type/pb_int.php: -------------------------------------------------------------------------------- 1 | value = $this->reader->next(); 17 | } 18 | 19 | /** 20 | * Serializes type 21 | */ 22 | public function SerializeToString($rec=-1) 23 | { 24 | // first byte is length byte 25 | $string = ''; 26 | 27 | if ($rec > -1) 28 | { 29 | $string .= $this->base128->set_value($rec << 3 | $this->wired_type); 30 | } 31 | 32 | $value = $this->base128->set_value($this->value); 33 | $string .= $value; 34 | 35 | return $string; 36 | } 37 | } 38 | ?> 39 | -------------------------------------------------------------------------------- /src/getui/igetui/IGt.TagMessage.php: -------------------------------------------------------------------------------- 1 | appIdList; 16 | } 17 | 18 | function set_appIdList($appIdList) { 19 | $this->appIdList = $appIdList; 20 | } 21 | 22 | function get_tag() { 23 | return $this->tag; 24 | } 25 | 26 | function set_tag($tag) { 27 | $this->tag = $tag; 28 | } 29 | 30 | function get_speed() 31 | { 32 | return $this->speed; 33 | } 34 | function set_speed($speed) 35 | { 36 | $this->speed=$speed; 37 | } 38 | } -------------------------------------------------------------------------------- /src/Exceptions/PushException.php: -------------------------------------------------------------------------------- 1 | '系统内部错误', 14 | '1001' => '只支持 HTTP Post 方法', 15 | '1002' => '缺少了必须的参数', 16 | '1003' => '参数值不合法', 17 | '1004' => '验证失败', 18 | '1005' => '消息体太大', 19 | '1008' => 'app_key参数非法', 20 | '1009' => '推送对象中有不支持的key', 21 | '1011' => '没有满足条件的推送目标', 22 | '1020' => '只支持 HTTPS 请求', 23 | '1030' => '内部服务超时', 24 | '2002' => 'API调用频率超出该应用的限制', 25 | '2003' => '该应用appkey已被限制调用 API', 26 | '2004' => '无权限执行当前操作', 27 | '2005' => '信息发送量超出合理范围。', 28 | ]; 29 | public function __construct($code) 30 | { 31 | parent::__construct(self::$errorMsgs[$code], $code); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/getui/protobuf/type/pb_signed_int.php: -------------------------------------------------------------------------------- 1 | value; 19 | $this->value = round($this->value / 2); 20 | if ($saved % 2 == 1) 21 | { 22 | $this->value = -($this->value); 23 | } 24 | } 25 | 26 | /** 27 | * Serializes type 28 | */ 29 | public function SerializeToString($rec=-1) 30 | { 31 | // now convert signed int to int 32 | $save = $this->value; 33 | if ($this->value < 0) 34 | { 35 | $this->value = abs($this->value)*2-1; 36 | } 37 | else 38 | { 39 | $this->value = $this->value*2; 40 | } 41 | $string = parent::SerializeToString($rec); 42 | // restore value 43 | $this->value = $save; 44 | 45 | return $string; 46 | } 47 | } 48 | ?> 49 | -------------------------------------------------------------------------------- /src/Message.php: -------------------------------------------------------------------------------- 1 | title = $title; 23 | 24 | return $this; 25 | } 26 | 27 | /** 28 | * @return mixed 29 | */ 30 | public function getTitle() 31 | { 32 | return $this->title; 33 | } 34 | 35 | /** 36 | * @param mixed $content 37 | * 38 | * @return Message 39 | */ 40 | public function setContent($content) 41 | { 42 | $this->content = $content; 43 | 44 | return $this; 45 | } 46 | 47 | /** 48 | * @return mixed 49 | */ 50 | public function getContent() 51 | { 52 | return $this->content; 53 | } 54 | } -------------------------------------------------------------------------------- /src/getui/protobuf/type/pb_bytes.php: -------------------------------------------------------------------------------- 1 | value = ''; 17 | // first byte is length 18 | $length = $this->reader->next(); 19 | 20 | // just extract the string 21 | $pointer = $this->reader->get_pointer(); 22 | $this->reader->add_pointer($length); 23 | $this->value = $this->reader->get_message_from($pointer); 24 | } 25 | 26 | /** 27 | * Serializes type 28 | */ 29 | public function SerializeToString($rec = -1) 30 | { 31 | $string = ''; 32 | 33 | if ($rec > -1) 34 | { 35 | $string .= $this->base128->set_value($rec << 3 | $this->wired_type); 36 | } 37 | 38 | $string .= $this->base128->set_value(strlen($this->value)); 39 | $string .= $this->value; 40 | 41 | return $string; 42 | } 43 | } 44 | ?> 45 | -------------------------------------------------------------------------------- /src/getui/protobuf/type/pb_string.php: -------------------------------------------------------------------------------- 1 | value = ''; 17 | // first byte is length 18 | $length = $this->reader->next(); 19 | 20 | // just extract the string 21 | $pointer = $this->reader->get_pointer(); 22 | $this->reader->add_pointer($length); 23 | $this->value = $this->reader->get_message_from($pointer); 24 | } 25 | 26 | /** 27 | * Serializes type 28 | */ 29 | public function SerializeToString($rec = -1) 30 | { 31 | $string = ''; 32 | 33 | if ($rec > -1) 34 | { 35 | $string .= $this->base128->set_value($rec << 3 | $this->wired_type); 36 | } 37 | 38 | $string .= $this->base128->set_value(strlen($this->value)); 39 | $string .= $this->value; 40 | 41 | return $string; 42 | } 43 | } 44 | ?> 45 | -------------------------------------------------------------------------------- /src/getui/protobuf/reader/pb_input_reader.php: -------------------------------------------------------------------------------- 1 | base128 = new base128varint(1); 15 | } 16 | 17 | /** 18 | * Gets the acutal position of the point 19 | * @return int the pointer 20 | */ 21 | public function get_pointer() 22 | { 23 | return $this->pointer; 24 | } 25 | 26 | /** 27 | * Add add to the pointer 28 | * @param int $add - int to add to the pointer 29 | */ 30 | public function add_pointer($add) 31 | { 32 | $this->pointer += $add; 33 | } 34 | 35 | /** 36 | * Get the message from from to actual pointer 37 | * @param from 38 | */ 39 | public function get_message_from($from) 40 | { 41 | return substr($this->string, $from, $this->pointer - $from); 42 | } 43 | 44 | /** 45 | * Getting the next varint as decimal number 46 | * @return varint 47 | */ 48 | public abstract function next(); 49 | } 50 | ?> 51 | -------------------------------------------------------------------------------- /src/getui/igetui/utils/LangUtils.php: -------------------------------------------------------------------------------- 1 | isOffline; 25 | } 26 | function set_isOffline($isOffline) 27 | { 28 | return $this->isOffline = $isOffline; 29 | } 30 | function get_offlineExpireTime() 31 | { 32 | return $this->offlineExpireTime; 33 | } 34 | function set_offlineExpireTime($offlineExpireTime) 35 | { 36 | return $this->offlineExpireTime = $offlineExpireTime; 37 | } 38 | function get_pushNetWorkType() 39 | { 40 | return $this->pushNetWorkType; 41 | } 42 | function set_pushNetWorkType($pushNetWorkType) 43 | { 44 | return $this->pushNetWorkType = $pushNetWorkType; 45 | } 46 | function get_data() 47 | { 48 | return $this->data; 49 | } 50 | function set_data($data) 51 | { 52 | return $this->data = $data; 53 | } 54 | } -------------------------------------------------------------------------------- /src/getui/protobuf/reader/pb_input_string_reader.php: -------------------------------------------------------------------------------- 1 | string = $string; 13 | $this->length = strlen($string); 14 | } 15 | 16 | /** 17 | * get the next 18 | * @param boolean $is_string - if set to true only one byte is read 19 | */ 20 | public function next($is_string = false) 21 | { 22 | $package = ''; 23 | while (true) 24 | { 25 | if ($this->pointer >= $this->length) 26 | { 27 | return false; 28 | } 29 | 30 | $string = ''; 31 | $string = $this->string[$this->pointer]; 32 | $this->pointer++; 33 | 34 | if ($is_string == true) 35 | return ord($string); 36 | 37 | $value = decbin(ord($string)); 38 | 39 | if ($value >= 10000000 && $is_string == false) 40 | { 41 | // now fill to eight with 00 42 | $package .= $value; 43 | } 44 | else 45 | { 46 | // now fill to length of eight with 0 47 | $value = substr('00000000', 0, 8 - strlen($value) % 8) . $value; 48 | return $this->base128->get_value($package . $value); 49 | } 50 | } 51 | } 52 | } 53 | ?> 54 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shaozeming/laravel-getui", 3 | "description": "一个适用于laravel和lumen框架的个推push推送服务包", 4 | "type": "library", 5 | "require": { 6 | "illuminate/container": "^5.1", 7 | "php": ">=7.1.3", 8 | "ext-json": "*", 9 | "ext-mbstring": "*", 10 | "ext-openssl": "*", 11 | "vlucas/phpdotenv": "^3.0" 12 | }, 13 | "require-dev": { 14 | "phpunit/phpunit": "^6.3", 15 | "mockery/mockery": "^0.9.9" 16 | }, 17 | "autoload": { 18 | "psr-4": { 19 | "ShaoZeMing\\GeTui\\": "./src" 20 | } 21 | }, 22 | "autoload-dev": { 23 | "psr-4": { 24 | "ShaoZeMing\\GeTui\\Tests\\": "./tests/" 25 | } 26 | }, 27 | "license": "MIT", 28 | "authors": [ 29 | { 30 | "name": "Shao ZeMing", 31 | "email": "szm19920426@gmail.com" 32 | } 33 | ], 34 | "extra": { 35 | "laravel": { 36 | "providers": [ 37 | "ShaoZeMing\\GeTui\\GeTuiServiceProvider" 38 | ], 39 | "aliases": { 40 | "GeTui": "ShaoZeMing\\GeTui\\Facade\\GeTui" 41 | } 42 | } 43 | }, 44 | "minimum-stability":"dev" 45 | } 46 | -------------------------------------------------------------------------------- /src/getui/igetui/template/notify/IGt.Notify.php: -------------------------------------------------------------------------------- 1 | title; 32 | } 33 | 34 | /** 35 | * @param mixed $title 36 | */ 37 | public function set_title($title) 38 | { 39 | $this->title = $title; 40 | } 41 | 42 | /** 43 | * @return mixed 44 | */ 45 | public function get_content() 46 | { 47 | return $this->content; 48 | } 49 | 50 | /** 51 | * @param mixed $content 52 | */ 53 | public function set_content($content) 54 | { 55 | $this->content = $content; 56 | } 57 | 58 | /** 59 | * @return mixed 60 | */ 61 | public function get_payload() 62 | { 63 | return $this->payload; 64 | } 65 | 66 | /** 67 | * @param mixed $payload 68 | */ 69 | public function set_payload($payload) 70 | { 71 | $this->payload = $payload; 72 | } 73 | } -------------------------------------------------------------------------------- /src/getui/igetui/utils/AppConditions.php: -------------------------------------------------------------------------------- 1 | condition[] = $item; 43 | return $this; 44 | } 45 | function addCondition2($key, $values) { 46 | return $this->addCondition3($key, $values, 0); 47 | } 48 | 49 | function getCondition() { 50 | return $this->condition; 51 | } 52 | } 53 | ?> -------------------------------------------------------------------------------- /src/getui/igetui/IGt.MultiMedia.php: -------------------------------------------------------------------------------- 1 | rid; 31 | } 32 | 33 | function set_rid($rid) { 34 | $this->rid = $rid; 35 | return $this; 36 | } 37 | 38 | function get_url() { 39 | return $this->url; 40 | } 41 | 42 | function set_url($url) { 43 | $this->url = $url; 44 | return$this; 45 | } 46 | 47 | function get_type() { 48 | return $this -> type; 49 | } 50 | 51 | function set_type($type) { 52 | $this -> type = $type; 53 | return $this; 54 | } 55 | 56 | function set_onlywifi($onlywifi) { 57 | $this -> onlywifi = $onlywifi ? 1:0; 58 | return $this; 59 | } 60 | 61 | function get_onlywifi() { 62 | return $this -> onlywifi; 63 | } 64 | } 65 | 66 | class MediaType { 67 | const __default = self::pic; 68 | 69 | const pic = 1; 70 | const audio = 2; 71 | const video = 3; 72 | } 73 | -------------------------------------------------------------------------------- /src/GeTuiServiceProvider.php: -------------------------------------------------------------------------------- 1 | app instanceof LaravelApplication && $this->app->runningInConsole()) { 28 | $this->publishes([$source => config_path('getui.php')]); 29 | } elseif ($this->app instanceof LumenApplication) { 30 | $this->app->configure('getui'); 31 | } 32 | $this->mergeConfigFrom($source, 'getui'); 33 | 34 | } 35 | 36 | /** 37 | * Register any application services. 38 | * 39 | * @return void 40 | */ 41 | public function register() 42 | { 43 | $this->app->singleton(GeTuiService::class, function ($app) { 44 | return new GeTuiService($app->config->get('getui', [])); 45 | }); 46 | $this->app->alias(GeTuiService::class, 'getui'); 47 | 48 | } 49 | 50 | public function provides() 51 | { 52 | return [GeTuiService::class,'getui']; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /tests/PushTest.php: -------------------------------------------------------------------------------- 1 | instance = new GeTuiService($config); 26 | } 27 | 28 | 29 | public function testPushManager() 30 | { 31 | $this->assertInstanceOf(GeTuiService::class, $this->instance); 32 | } 33 | 34 | 35 | public function testPush() 36 | { 37 | echo PHP_EOL."发送push 中....".PHP_EOL; 38 | try { 39 | $deviceId = '2e682657977c5c616481ae76088b033d'; 40 | $title = '噪音好大啊,啊,啊,啊啊,'; 41 | $content = '你好呀您负责的的工单已经追加元'; 42 | 43 | $data = [ 44 | 'type' => 9, 45 | 'title' => $title, 46 | 'content' => $content, 47 | ]; 48 | 49 | $getuiResponse = $this->instance->push($deviceId, $data); 50 | // $getuiResponse = $this->instance->pushToApp( $data); 51 | echo json_encode($getuiResponse).PHP_EOL; 52 | // $this->assertContains('ok',$getuiResponse,'不成功'); 53 | // return $getuiResponse; 54 | } catch (\Exception $e) { 55 | 56 | 57 | $err = "Error : 错误:" . $e->getMessage(); 58 | echo $err.PHP_EOL; 59 | 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/config/getui.php: -------------------------------------------------------------------------------- 1 | env('APP_ENV') == 'production' ? 'production' : 'development', 5 | 6 | // The default default_client name which configured in `development` or `production` section 7 | 'default_client' => 'client_1', 8 | 9 | 10 | 'development' => [ 11 | 'client_1' => [ 12 | 'gt_appid' => '87klYMPe1o515SCcbx7Co5', 13 | 'gt_appkey' => 'dd9XpsgHff89DJgUgvW6L8', 14 | 'gt_appsecret' => 'aKMLyeXLCc8hFpjcuf8gW8', 15 | 'gt_mastersecret' => 'zx85PndZVf8Q1M1Iv9dEy3', 16 | 'gt_domainurl' => 'http://sdk.open.api.igexin.com/apiex.htm', 17 | ], 18 | 'client_2' => [ 19 | 'gt_appid' => '87klYMPe1o515SCcbx7Co5', 20 | 'gt_appkey' => 'dd9XpsgHff89DJgUgvW6L8', 21 | 'gt_appsecret' => 'aKMLyeXLCc8hFpjcuf8gW8', 22 | 'gt_mastersecret' => 'zx85PndZVf8Q1M1Iv9dEy3', 23 | 'gt_domainurl' => 'http://sdk.open.api.igexin.com/apiex.htm', 24 | ], 25 | 26 | // other client_3 ...... 27 | ], 28 | 'production' => [ 29 | 'client_1' => [ 30 | 'gt_appid' => '87klYMPe1o515SCcbx7Co5', 31 | 'gt_appkey' => 'dd9XpsgHff89DJgUgvW6L8', 32 | 'gt_appsecret' => 'aKMLyeXLCc8hFpjcuf8gW8', 33 | 'gt_mastersecret' => 'zx85PndZVf8Q1M1Iv9dEy3', 34 | 'gt_domainurl' => 'http://sdk.open.api.igexin.com/apiex.htm', 35 | ], 36 | 'client_2' => [ 37 | 'gt_appid' => '87klYMPe1o515SCcbx7Co5', 38 | 'gt_appkey' => 'dd9XpsgHff89DJgUgvW6L8', 39 | 'gt_appsecret' => 'aKMLyeXLCc8hFpjcuf8gW8', 40 | 'gt_mastersecret' => 'zx85PndZVf8Q1M1Iv9dEy3', 41 | 'gt_domainurl' => 'http://sdk.open.api.igexin.com/apiex.htm', 42 | ], 43 | 44 | // other client_3 ...... 45 | 46 | ], 47 | ]; 48 | -------------------------------------------------------------------------------- /src/getui/igetui/utils/ApiUrlRespectUtils.php: -------------------------------------------------------------------------------- 1 | $diff) 48 | { 49 | $mint=$diff; 50 | $s_url=$hosts[$i]; 51 | } 52 | } 53 | return $s_url; 54 | } 55 | } -------------------------------------------------------------------------------- /src/getui/igetui/IGt.AppMessage.php: -------------------------------------------------------------------------------- 1 | appIdList; 24 | } 25 | 26 | function set_appIdList($appIdList) { 27 | $this->appIdList = $appIdList; 28 | } 29 | 30 | /** 31 | * @deprecated deprecated since version 4.0.0.3 32 | */ 33 | function get_phoneTypeList() { 34 | return $this->phoneTypeList; 35 | } 36 | 37 | /** 38 | * @deprecated deprecated since version 4.0.0.3 39 | */ 40 | function set_phoneTypeList($phoneTypeList) { 41 | $this->phoneTypeList = $phoneTypeList; 42 | } 43 | 44 | /** 45 | * @deprecated deprecated since version 4.0.0.3 46 | */ 47 | function get_provinceList() { 48 | return $this->provinceList; 49 | } 50 | 51 | /** 52 | * @deprecated deprecated since version 4.0.0.3 53 | */ 54 | function set_provinceList($provinceList) { 55 | $this->provinceList = $provinceList; 56 | } 57 | 58 | /** 59 | * @deprecated deprecated since version 4.0.0.3 60 | */ 61 | function get_tagList() { 62 | return $this->tagList; 63 | } 64 | 65 | /** 66 | * @deprecated deprecated since version 4.0.0.3 67 | */ 68 | function set_tagList($tagList) { 69 | $this->tagList = $tagList; 70 | } 71 | 72 | public function get_conditions() 73 | { 74 | return $this->conditions; 75 | } 76 | 77 | public function set_conditions($conditions) 78 | { 79 | $this->conditions = $conditions; 80 | } 81 | 82 | function get_speed() 83 | { 84 | return $this->speed; 85 | } 86 | function set_speed($speed) 87 | { 88 | $this->speed=$speed; 89 | } 90 | } -------------------------------------------------------------------------------- /src/getui/igetui/template/IGt.TransmissionTemplate.php: -------------------------------------------------------------------------------- 1 | set_actionId(1); 16 | $actionChain1->set_type(ActionChain_Type::refer); 17 | $actionChain1->set_next(10030); 18 | 19 | //appStartUp 20 | $appStartUp = new AppStartUp(); 21 | $appStartUp->set_android(""); 22 | $appStartUp->set_symbia(""); 23 | $appStartUp->set_ios(""); 24 | 25 | //启动app 26 | $actionChain2 = new ActionChain(); 27 | $actionChain2->set_actionId(10030); 28 | $actionChain2->set_type(ActionChain_Type::startapp); 29 | $actionChain2->set_appid(""); 30 | $actionChain2->set_autostart($this->transmissionType == '1'? true : false); 31 | $actionChain2->set_appstartupid($appStartUp); 32 | $actionChain2->set_failedAction(100); 33 | $actionChain2->set_next(100); 34 | 35 | //结束 36 | $actionChain3 = new ActionChain(); 37 | $actionChain3->set_actionId(100); 38 | $actionChain3->set_type(ActionChain_Type::eoa); 39 | 40 | 41 | array_push($actionChains, $actionChain1,$actionChain2,$actionChain3); 42 | 43 | return $actionChains; 44 | } 45 | 46 | function get_transmissionContent() { 47 | return $this->transmissionContent; 48 | } 49 | 50 | function get_pushType() { 51 | return 'TransmissionMsg'; 52 | } 53 | 54 | 55 | function set_transmissionType($transmissionType) { 56 | $this->transmissionType = $transmissionType; 57 | } 58 | 59 | function set_transmissionContent($transmissionContent) { 60 | $this->transmissionContent = $transmissionContent; 61 | } 62 | 63 | function set3rdNotifyInfo($notify) { 64 | if ($notify->get_title() == null || $notify -> get_content() == null) { 65 | throw new Exception("notify title or content cannot be null"); 66 | } 67 | 68 | $notifyInfo = new NotifyInfo(); 69 | $notifyInfo -> set_title($notify -> get_title()); 70 | $notifyInfo -> set_content($notify -> get_content()); 71 | $notifyInfo -> set_payload($notify -> get_payload()); 72 | 73 | $pushInfo = $this-> get_pushInfo(); 74 | $pushInfo -> set_notifyInfo($notifyInfo); 75 | $pushInfo -> set_validNotify(true); 76 | } 77 | } -------------------------------------------------------------------------------- /src/getui/IGt.Batch.php: -------------------------------------------------------------------------------- 1 | APPKEY = $appkey; 23 | $this->push = $push; 24 | $this->batchId = uniqid(); 25 | 26 | } 27 | 28 | public function getBatchId() 29 | { 30 | return $this->batchId; 31 | } 32 | 33 | public function add($message, $target) 34 | { 35 | if ($this->seqId >= 5000) { 36 | throw new Exception("Can not add over 5000 message once! Please call submit() first."); 37 | } else { 38 | $this->seqId += 1; 39 | $innerMsg = new SingleBatchItem(); 40 | $innerMsg->set_seqId($this->seqId); 41 | $innerMsg->set_data($this->createSingleJson($message, $target)); 42 | array_push($this->innerMsgList, $innerMsg); 43 | } 44 | return $this->seqId . ""; 45 | } 46 | 47 | public function createSingleJson($message, $target) 48 | { 49 | $params = $this->push->getSingleMessagePostData($message,$target); 50 | return json_encode($params); 51 | } 52 | 53 | public function submit() 54 | { 55 | $requestId = uniqid(); 56 | $data = array(); 57 | $data["appkey"]=$this->APPKEY; 58 | $data["serialize"] = "pb"; 59 | $data["async"] = GTConfig::isPushSingleBatchAsync(); 60 | $data["action"] = "pushMessageToSingleBatchAction"; 61 | $data['requestId'] = $requestId; 62 | $singleBatchRequest = new SingleBatchRequest(); 63 | $singleBatchRequest->set_batchId($this->batchId); 64 | foreach ($this->innerMsgList as $index => $innerMsg) { 65 | $singleBatchRequest->add_batchItem(); 66 | $singleBatchRequest->set_batchItem($index, $innerMsg); 67 | } 68 | $data["singleDatas"] = base64_encode($singleBatchRequest->SerializeToString()); 69 | $this->seqId = 0; 70 | $this->innerMsgList = array(); 71 | $this->lastPostData = $data; 72 | $result = $this->push->httpPostJSON(null, $data, true); 73 | return $result; 74 | } 75 | 76 | public function retry() 77 | { 78 | $result = $this->push->httpPostJSON(null, $this->lastPostData, true); 79 | return $result; 80 | } 81 | 82 | public function setApiUrl($apiUrl) { 83 | } 84 | } -------------------------------------------------------------------------------- /src/getui/protobuf/encoding/pb_base128.php: -------------------------------------------------------------------------------- 1 | modus = $modus; 18 | } 19 | 20 | 21 | /** 22 | * @param $number - number as decimal 23 | * Returns the base128 value of an dec value 24 | */ 25 | public function set_value($number) 26 | { 27 | $string = decbin($number); 28 | if (strlen($string) < 8) 29 | { 30 | $hexstring = dechex(bindec($string)); 31 | if (strlen($hexstring) % 2 == 1) 32 | $hexstring = '0' . $hexstring; 33 | if ($this->modus == 1) 34 | { 35 | return $this->hex_to_str($hexstring); 36 | } 37 | return $hexstring; 38 | } 39 | 40 | // split it and insert the mb byte 41 | $string_array = array(); 42 | $pre = '1'; 43 | while (strlen($string) > 0) 44 | { 45 | if (strlen($string) < 8) 46 | { 47 | $string = substr('00000000', 0, 7 - strlen($string) % 7) . $string; 48 | $pre = '0'; 49 | } 50 | $string_array[] = $pre . substr($string, strlen($string) - 7, 7); 51 | $string = substr($string, 0, strlen($string) - 7); 52 | $pre = '1'; 53 | if ($string == '0000000') 54 | break; 55 | } 56 | 57 | $hexstring = ''; 58 | foreach ($string_array as $string) 59 | { 60 | $hexstring .= sprintf('%02X', bindec($string)); 61 | } 62 | 63 | // now format to hexstring in the right format 64 | if ($this->modus == 1) 65 | { 66 | return $this->hex_to_str($hexstring); 67 | } 68 | 69 | return $hexstring; 70 | } 71 | 72 | 73 | /** 74 | * Returns the dec value of an base128 75 | * @param string bstring 76 | */ 77 | public function get_value($string) 78 | { 79 | // now just drop the msb and reorder it + parse it in own string 80 | $valuestring = ''; 81 | $string_length = strlen($string); 82 | 83 | $i = 1; 84 | 85 | while ($string_length > $i) 86 | { 87 | // unset msb string and reorder it 88 | $valuestring = substr($string, $i, 7) . $valuestring; 89 | $i += 8; 90 | } 91 | 92 | // now interprete it 93 | return bindec($valuestring); 94 | } 95 | 96 | /** 97 | * Converts hex 2 ascii 98 | * @param String $hex - the hex string 99 | */ 100 | public function hex_to_str($hex) 101 | { 102 | $str = ''; 103 | 104 | for($i = 0; $i < strlen($hex); $i += 2) 105 | { 106 | $str .= chr(hexdec(substr($hex, $i, 2))); 107 | } 108 | return $str; 109 | } 110 | 111 | } 112 | 113 | ?> 114 | -------------------------------------------------------------------------------- /src/getui/igetui/utils/GTConfig.php: -------------------------------------------------------------------------------- 1 | = 462850) { 47 | curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, 30000); 48 | curl_setopt($curl, CURLOPT_NOSIGNAL, 1); 49 | } 50 | //通过代理访问接口需要在此处配置代理 51 | //curl_setopt($curl, CURLOPT_PROXY, '192.168.1.18:808'); 52 | //请求失败有3次重试机会 53 | $result = HttpManager::exeBySetTimes(3, $curl); 54 | //curl_close($curl); 55 | return $result; 56 | } 57 | 58 | public static function httpHead($url) 59 | { 60 | $curl = curl_init($url); 61 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 62 | curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1); 63 | curl_setopt($curl, CURLOPT_USERAGENT, 'GeTui PHP/1.0'); 64 | curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'HEAD'); 65 | curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, GTConfig::getHttpConnectionTimeOut()); 66 | curl_setopt($curl, CURLOPT_TIMEOUT_MS, GTConfig::getHttpSoTimeOut()); 67 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); 68 | curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); 69 | curl_setopt($curl, CURLOPT_NOBODY, 1); 70 | $header = array("Content-Type:text/html;charset=UTF-8"); 71 | curl_setopt($curl, CURLOPT_HTTPHEADER,$header); 72 | 73 | $curl_version = curl_version(); 74 | if ($curl_version['version_number'] >= 462850) { 75 | curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, 30000); 76 | curl_setopt($curl, CURLOPT_NOSIGNAL, 1); 77 | } 78 | //通过代理访问接口需要在此处配置代理 79 | //curl_setopt($curl, CURLOPT_PROXY, '192.168.1.18:808'); 80 | //请求失败有3次重试机会 81 | $result = HttpManager::exeBySetTimes(3, $curl); 82 | 83 | curl_close($curl); 84 | return $result; 85 | } 86 | 87 | public static function httpPostJson($url, $params, $gzip) 88 | { 89 | if(!isset($params["version"])) 90 | { 91 | $params["version"] = GTConfig::getSDKVersion(); 92 | } 93 | $action = $params["action"]; 94 | $data = json_encode($params); 95 | $result = null; 96 | try { 97 | $resp = HttpManager::httpPost($url, $data, $gzip, $action); 98 | //LogUtils::debug("发送请求 post:{$data} return:{$resp}"); 99 | $result = json_decode($resp, true); 100 | return $result; 101 | } catch (Exception $e) { 102 | throw new RequestException($params["requestId"],"httpPost:[".$url."] [" .$data." ] [ ".$result."]:",$e); 103 | } 104 | } 105 | 106 | private static function exeBySetTimes($count, $curl) 107 | { 108 | $result = curl_exec($curl); 109 | $info = curl_getinfo($curl); 110 | $code = $info["http_code"]; 111 | 112 | if (curl_errno($curl) != 0 && $code != 200) { 113 | LogUtils::debug("request errno: ".curl_errno($curl).",url:".$info["url"]); 114 | $count--; 115 | if ($count > 0) { 116 | $result = HttpManager::exeBySetTimes($count, $curl); 117 | } 118 | } 119 | return $result; 120 | } 121 | } -------------------------------------------------------------------------------- /src/getui/igetui/template/IGt.LinkTemplate.php: -------------------------------------------------------------------------------- 1 | set_actionId(1); 54 | $actionChain1->set_type(ActionChain_Type::refer); 55 | $actionChain1->set_next(10000); 56 | 57 | //通知 58 | $actionChain2 = new ActionChain(); 59 | $actionChain2->set_actionId(10000); 60 | $actionChain2->set_type(ActionChain_Type::mmsinbox2); 61 | $actionChain2->set_stype("notification"); 62 | 63 | $f_text = new InnerFiled(); 64 | $f_text->set_key("text"); 65 | $f_text->set_val($this->text); 66 | $f_text->set_type(InnerFiled_Type::str); 67 | $actionChain2->set_field(0,$f_text); 68 | 69 | $f_title = new InnerFiled(); 70 | $f_title->set_key("title"); 71 | $f_title->set_val($this->title); 72 | $f_title->set_type(InnerFiled_Type::str); 73 | $actionChain2->set_field(1,$f_title); 74 | 75 | $f_logo = new InnerFiled(); 76 | $f_logo->set_key("logo"); 77 | $f_logo->set_val($this->logo); 78 | $f_logo->set_type(InnerFiled_Type::str); 79 | $actionChain2->set_field(2,$f_logo); 80 | 81 | $f_logoURL = new InnerFiled(); 82 | $f_logoURL->set_key("logo_url"); 83 | $f_logoURL->set_val($this->logoURL); 84 | $f_logoURL->set_type(InnerFiled_Type::str); 85 | $actionChain2->set_field(3,$f_logoURL); 86 | 87 | $f_notifyStyle = new InnerFiled(); 88 | $f_notifyStyle->set_key("notifyStyle"); 89 | $f_notifyStyle->set_val(strval($this->notifyStyle)); 90 | $f_notifyStyle->set_type(InnerFiled_Type::str); 91 | $actionChain2->set_field(4,$f_notifyStyle); 92 | 93 | $f_isRing = new InnerFiled(); 94 | $f_isRing->set_key("is_noring"); 95 | $f_isRing->set_val(!$this->isRing ? "true" : "false"); 96 | $f_isRing->set_type(InnerFiled_Type::bool); 97 | $actionChain2->set_field(5,$f_isRing); 98 | 99 | $f_isVibrate = new InnerFiled(); 100 | $f_isVibrate->set_key("is_novibrate"); 101 | $f_isVibrate->set_val(!$this->isVibrate ? "true" : "false"); 102 | $f_isVibrate->set_type(InnerFiled_Type::bool); 103 | $actionChain2->set_field(6,$f_isVibrate); 104 | 105 | $f_isClearable = new InnerFiled(); 106 | $f_isClearable->set_key("is_noclear"); 107 | $f_isClearable->set_val(!$this->isClearable ? "true" : "false"); 108 | $f_isClearable->set_type(InnerFiled_Type::bool); 109 | $actionChain2->set_field(7,$f_isClearable); 110 | 111 | $actionChain2->set_next(10010); 112 | 113 | $actionChain3 = new ActionChain(); 114 | $actionChain3->set_actionId(10010); 115 | $actionChain3->set_type(ActionChain_Type::refer); 116 | $actionChain3->set_next(10020); 117 | 118 | 119 | //goto 120 | $actionChain3 = new ActionChain(); 121 | $actionChain3->set_actionId(10010); 122 | $actionChain3->set_type(ActionChain_Type::refer); 123 | $actionChain3->set_next(10040); 124 | 125 | 126 | //启动web 127 | $actionChain4 = new ActionChain(); 128 | $actionChain4->set_actionId(10040); 129 | $actionChain4->set_type(ActionChain_Type::startweb); 130 | $actionChain4->set_url($this->url); 131 | $actionChain4->set_next(100); 132 | 133 | 134 | //结束 135 | $actionChain5 = new ActionChain(); 136 | $actionChain5->set_actionId(100); 137 | $actionChain5->set_type(ActionChain_Type::eoa); 138 | 139 | array_push($actionChains, $actionChain1,$actionChain2,$actionChain3,$actionChain4,$actionChain5); 140 | 141 | return $actionChains; 142 | } 143 | 144 | function get_pushType() { 145 | return 'LinkMsg'; 146 | } 147 | 148 | function set_text($text) { 149 | $this->text = $text; 150 | } 151 | 152 | function set_title($title) { 153 | $this->title = $title; 154 | } 155 | 156 | function set_logo($logo) { 157 | $this->logo = $logo; 158 | } 159 | 160 | function set_logoURL($logoURL) { 161 | $this->logoURL = $logoURL; 162 | } 163 | 164 | function set_url($url) { 165 | $this->url = $url; 166 | } 167 | 168 | function set_isRing($isRing) { 169 | $this->isRing = $isRing; 170 | } 171 | 172 | function set_isVibrate($isVibrate) { 173 | $this->isVibrate = $isVibrate; 174 | } 175 | 176 | function set_isClearable($isClearable) { 177 | $this->isClearable = $isClearable; 178 | } 179 | 180 | function set_notifyStyle($notifyStyle) { 181 | if($notifyStyle != 1){ 182 | $this->notifyStyle = 0; 183 | } else { 184 | $this->notifyStyle = 1; 185 | } 186 | } 187 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Laravel Or Lumen GeTui 2 | 3 | 基于 [个推官方SDK](http://docs.getui.com/getui/server/php/start/) for Laravel. 4 | 5 | 6 | --- 7 | [![](https://travis-ci.org/ShaoZeMing/laravel-getui.svg?branch=master)](https://travis-ci.org/ShaoZeMing/laravel-getui) 8 | [![](https://img.shields.io/packagist/v/ShaoZeMing/laravel-getui.svg)](https://packagist.org/packages/shaozeming/laravel-getui) 9 | [![](https://img.shields.io/packagist/dt/ShaoZeMing/laravel-getui.svg)](https://packagist.org/packages/stichoza/shaozeming/laravel-getui) 10 | 11 | ## 安装 12 | 13 | ```shell 14 | $ composer require shaozeming/laravel-getui -v 15 | ``` 16 | ### Laravel 17 | 18 | 19 | 20 | ```php 21 | // config/app.php 22 | 23 | 'providers' => [ 24 | //... 25 | ShaoZeMing\GeTui\GeTuiServiceProvider::class, //This is default in laravel 5.5 26 | ], 27 | ``` 28 | 29 | And publish the config file: 30 | 31 | ```shell 32 | $ php artisan vendor:publish --provider=ShaoZeMing\\GeTui\\GeTuiServiceProvider 33 | ``` 34 | 35 | if you want to use facade mode, you can register a facade name what you want to use, for example `GeTui`: 36 | 37 | ```php 38 | // config/app.php 39 | 40 | 'aliases' => [ 41 | 'GeTui' => ShaoZeMing\GeTui\Facade\GeTui::class, //This is default in laravel 5.5 42 | ], 43 | ``` 44 | 45 | ### lumen 46 | 47 | - 在 bootstrap/app.php 中 82 行左右: 48 | ``` 49 | $app->register(ShaoZeMing\GeTui\GeTuiServiceProvider::class); 50 | ``` 51 | 将 `vendor/ShaoZeMing/laravel-getui/src/config/getui.php` 拷贝到项目根目录`/config`目录下,并将文件名改成`getui.php`。 52 | 53 | ### configuration 54 | 55 | ```php 56 | // config/getui.php 57 | // APP_EVN 你的项目当前环境 测试、生产 58 | 'app_env' => env('APP_ENV') == 'production' ? 'production' : 'development', 59 | 60 | 61 | // The default default_client name which configured in `development` or `production` section 62 | //默认推送的客户端 63 | 'default_client' => 'client_1', 64 | 65 | 66 | 'development' => [ 67 | 'client_1' => [ 68 | 'gt_appid' => 'WAqyXNcLpS8OLg4jBywS48', 69 | 'gt_appkey' => 'FkxUuibQsT75FX5Tt5jteA', 70 | 'gt_appsecret' => 'jWtd0iUzdmAvVPhKorrtW1', 71 | 'gt_mastersecret' => '4uCfJsfME99oaF5sT1ZjO', 72 | 'gt_domainurl' => 'http://sdk.open.api.igexin.com/apiex.htm', 73 | ], 74 | 'client_2' => [ 75 | 'gt_appid' => 'SeldZ6X0Iq8hpj5rGvqAk8', 76 | 'gt_appkey' => '93MPU2THwl9okpeNf4lNI4', 77 | 'gt_appsecret' => 'kzZuSXVMm29M7owpvId979', 78 | 'gt_mastersecret' => '0QCmCdVZSi8lcyMFXLB4e', 79 | 'gt_domainurl' => 'http://sdk.open.api.igexin.com/apiex.htm', 80 | ], 81 | 82 | // other client_3 ...... 83 | ], 84 | 'production' => [ 85 | 'client_1' => [ 86 | 'gt_appid' => '6V95sH0t3W6Du1MTiU3679', 87 | 'gt_appkey' => 'n6q8NSAshP77ImKxdhuHV6', 88 | 'gt_appsecret' => '01hGwR1Jdl6vuwBcnvfyD3', 89 | 'gt_mastersecret' => 'daw4hbkFj4Ah3kBlPFfIh2', 90 | 'gt_domainurl' => 'http://sdk.open.api.igexin.com/apiex.htm', 91 | ], 92 | 'client_2' => [ 93 | 'gt_appid' => 'iB7DfaXV6bAf8zlJ0L59A8', 94 | 'gt_appkey' => 'DKKp54s2knA2MaeGBXuF01', 95 | 'gt_appsecret' => 'exTKWC0M1K6O2Bgig5RiC8', 96 | 'gt_mastersecret' => '0cojzBC7yB86mhOiOVHBuA', 97 | 'gt_domainurl' => 'http://sdk.open.api.igexin.com/apiex.htm', 98 | ], 99 | 100 | // other client_3 ...... 101 | 102 | ], 103 | 104 | ``` 105 | 106 | 107 | ## Usage 108 | 109 | Gateway instance: 110 | 111 | ```php 112 | use GeTui; 113 | //针对单个或者多个用户推送 114 | GeTui::push($deviceId, $data,true) //Using default default_client 推送给默认的客户端 115 | GeTui::toClient('CLIENT NAME')->push($deviceId, $data) // CLIENT NAME is key name of `development` or `production` configuration. //自定义发送的客户端 116 | 117 | // 针对整个app所有人推送 118 | GeTui::pushToApp($data,true) ////Using default default_client 119 | GeTui::toClient('CLIENT NAME')->pushToApp($data) // GATEWAY NAME is key name of `development` or `production` configuration. 120 | 121 | ``` 122 | 123 | 124 | Example: 125 | 126 | ```php 127 | $deviceId = 'a1f3e7c11ca97924be6f291f2c09714b'; 128 | // 多个push对象device_id 用数组传入 129 | // $deviceId = [ 130 | // 'a1f3e7c11ca97924be6f291f2c09714b', 131 | // 'ea34a4715b08b1b8d77aabf36c977cba', 132 | // ]; 133 | 134 | $data = [ 135 | 'url' => 'http://test.4d4k.com/push', 136 | 'type' => '点击查看\(^o^)/~', 137 | 'title' => '23232323fdf', 138 | 'content' => '今天天气真好', 139 | 'id' => '3a92y3GR1neZ', 140 | 'merchant_name' => '泽明科技', 141 | 'big_cat' => '电视机', 142 | 'full_address' => '北京市海淀区五道口清华大学', 143 | ]; 144 | 145 | 146 | $res = \GeTui::push($deviceId, $data,true); //Using default default_client 147 | 148 | print_r($res); 149 | 150 | 151 | ``` 152 | 153 | ## License 154 | 155 | MIT 156 | -------------------------------------------------------------------------------- /src/getui/igetui/template/IGt.NotificationTemplate.php: -------------------------------------------------------------------------------- 1 | set_actionId(1); 24 | $actionChain1->set_type(ActionChain_Type::refer); 25 | $actionChain1->set_next(10000); 26 | 27 | //通知 28 | $actionChain2 = new ActionChain(); 29 | $actionChain2->set_actionId(10000); 30 | $actionChain2->set_type(ActionChain_Type::mmsinbox2); 31 | $actionChain2->set_stype("notification"); 32 | 33 | $f_text = new InnerFiled(); 34 | $f_text->set_key("text"); 35 | $f_text->set_val($this->text); 36 | $f_text->set_type(InnerFiled_Type::str); 37 | $actionChain2->set_field(0,$f_text); 38 | 39 | $f_title = new InnerFiled(); 40 | $f_title->set_key("title"); 41 | $f_title->set_val($this->title); 42 | $f_title->set_type(InnerFiled_Type::str); 43 | $actionChain2->set_field(1,$f_title); 44 | 45 | $f_logo = new InnerFiled(); 46 | $f_logo->set_key("logo"); 47 | $f_logo->set_val($this->logo); 48 | $f_logo->set_type(InnerFiled_Type::str); 49 | $actionChain2->set_field(2,$f_logo); 50 | 51 | $f_logoURL = new InnerFiled(); 52 | $f_logoURL->set_key("logo_url"); 53 | $f_logoURL->set_val($this->logoURL); 54 | $f_logoURL->set_type(InnerFiled_Type::str); 55 | $actionChain2->set_field(3,$f_logoURL); 56 | 57 | $f_notifyStyle = new InnerFiled(); 58 | $f_notifyStyle->set_key("notifyStyle"); 59 | $f_notifyStyle->set_val(strval($this->notifyStyle)); 60 | $f_notifyStyle->set_type(InnerFiled_Type::str); 61 | $actionChain2->set_field(4,$f_notifyStyle); 62 | 63 | $f_isRing = new InnerFiled(); 64 | $f_isRing->set_key("is_noring"); 65 | $f_isRing->set_val(!$this->isRing ? "true" : "false"); 66 | $f_isRing->set_type(InnerFiled_Type::bool); 67 | $actionChain2->set_field(5,$f_isRing); 68 | 69 | $f_isVibrate = new InnerFiled(); 70 | $f_isVibrate->set_key("is_novibrate"); 71 | $f_isVibrate->set_val(!$this->isVibrate ? "true" : "false"); 72 | $f_isVibrate->set_type(InnerFiled_Type::bool); 73 | $actionChain2->set_field(6,$f_isVibrate); 74 | 75 | $f_isClearable = new InnerFiled(); 76 | $f_isClearable->set_key("is_noclear"); 77 | $f_isClearable->set_val(!$this->isClearable ? "true" : "false"); 78 | $f_isClearable->set_type(InnerFiled_Type::bool); 79 | $actionChain2->set_field(7,$f_isClearable); 80 | 81 | $actionChain2->set_next(10010); 82 | 83 | //goto 84 | $actionChain3 = new ActionChain(); 85 | $actionChain3->set_actionId(10010); 86 | $actionChain3->set_type(ActionChain_Type::refer); 87 | $actionChain3->set_next(10030); 88 | 89 | 90 | //appStartUp 91 | $appStartUp = new AppStartUp(); 92 | $appStartUp->set_android(""); 93 | $appStartUp->set_symbia(""); 94 | $appStartUp->set_ios(""); 95 | 96 | //启动app 97 | $actionChain4 = new ActionChain(); 98 | $actionChain4->set_actionId(10030); 99 | $actionChain4->set_type(ActionChain_Type::startapp); 100 | $actionChain4->set_appid(""); 101 | $actionChain4->set_autostart($this->transmissionType == '1'? true : false); 102 | $actionChain4->set_appstartupid($appStartUp); 103 | $actionChain4->set_failedAction(100); 104 | $actionChain4->set_next(100); 105 | 106 | 107 | //结束 108 | $actionChain5 = new ActionChain(); 109 | $actionChain5->set_actionId(100); 110 | $actionChain5->set_type(ActionChain_Type::eoa); 111 | 112 | array_push($actionChains, $actionChain1,$actionChain2,$actionChain3,$actionChain4,$actionChain5); 113 | 114 | return $actionChains; 115 | } 116 | 117 | function get_transmissionContent() { 118 | return $this->transmissionContent; 119 | } 120 | 121 | function get_pushType() { 122 | return 'NotifyMsg'; 123 | } 124 | 125 | function set_text($text) { 126 | $this->text = $text; 127 | } 128 | 129 | function set_title($title) { 130 | $this->title = $title; 131 | } 132 | 133 | function set_logo($logo) { 134 | $this->logo = $logo; 135 | } 136 | 137 | function set_logoURL($logoURL) { 138 | $this->logoURL = $logoURL; 139 | } 140 | 141 | function set_transmissionType($transmissionType) { 142 | $this->transmissionType = $transmissionType; 143 | } 144 | 145 | function set_isRing($isRing) { 146 | $this->isRing = $isRing; 147 | } 148 | 149 | function set_isVibrate($isVibrate) { 150 | $this->isVibrate = $isVibrate; 151 | } 152 | 153 | function set_isClearable($isClearable) { 154 | $this->isClearable = $isClearable; 155 | } 156 | 157 | function set_transmissionContent($transmissionContent) { 158 | $this->transmissionContent = $transmissionContent; 159 | } 160 | 161 | function set_notifyStyle($notifyStyle) { 162 | if($notifyStyle != 1){ 163 | $this->notifyStyle = 0; 164 | } else { 165 | $this->notifyStyle = 1; 166 | } 167 | } 168 | } -------------------------------------------------------------------------------- /src/getui/igetui/IGt.APNPayload.php: -------------------------------------------------------------------------------- 1 | alertMsg != null) { 31 | $msg = $this->alertMsg->get_alertMsg(); 32 | if($msg != null) 33 | { 34 | $apsMap["alert"] = $msg; 35 | } 36 | } 37 | 38 | if ($this->badge >= 0) { 39 | $apsMap["badge"] = $this->badge; 40 | } 41 | if($this -> sound == null || $this->sound == '' ) 42 | { 43 | $apsMap["sound"] = 'default'; 44 | }elseif($this->sound != $this->APN_SOUND_SILENCE) 45 | { 46 | $apsMap["sound"] = $this->sound; 47 | } 48 | 49 | if (sizeof($apsMap) == 0) { 50 | throw new Exception("format error"); 51 | } 52 | if ($this->contentAvailable > 0) { 53 | $apsMap["content-available"] = $this->contentAvailable; 54 | } 55 | if ($this->category != null && $this->category != "") { 56 | $apsMap["category"] = $this->category; 57 | } 58 | 59 | $map = array(); 60 | if(count($this->customMsg) > 0){ 61 | foreach ($this->customMsg as $key => $value) { 62 | $map[$key] = $value; 63 | } 64 | } 65 | $map["aps"] = $apsMap; 66 | 67 | if($this -> multiMedias != null && sizeof($this -> multiMedias) > 0) { 68 | $map["_grinfo_"] = $this->check_multiMedias(); 69 | } 70 | return json_encode($map); 71 | } catch (Exception $e) { 72 | throw new Exception("create apn payload error", -1, $e); 73 | } 74 | } 75 | 76 | public function add_customMsg($key, $value) 77 | { 78 | if ($key != null && $key != "" && $value != null) { 79 | $this->customMsg[$key] = $value; 80 | } 81 | } 82 | 83 | function check_multiMedias() 84 | { 85 | if(sizeof($this -> multiMedias) > 3) { 86 | throw new RuntimeException("MultiMedias size overlimit"); 87 | } 88 | 89 | $needGeneRid = false; 90 | $rids = array(); 91 | for($i = 0; $i < sizeof($this -> multiMedias); $i++) { 92 | $media = $this -> multiMedias[$i]; 93 | if($media -> get_rid() == null) { 94 | $needGeneRid = true; 95 | } else { 96 | $rids[$media -> get_rid()] = 0; 97 | } 98 | 99 | if($media->get_type() == null || $media->get_url() == null) { 100 | throw new RuntimeException("MultiMedia resType and resUrl can't be null"); 101 | } 102 | } 103 | 104 | if(sizeof($rids) != sizeof($this -> multiMedias)) { 105 | $needGeneRid = true; 106 | } 107 | if($needGeneRid) { 108 | for ($i = 0; $i < sizeof($this->multiMedias); $i++) { 109 | $this->multiMedias[$i] -> set_rid("grid-" . $i); 110 | } 111 | } 112 | 113 | return $this -> multiMedias; 114 | } 115 | 116 | function add_multiMedia($media) { 117 | $this->multiMedias[] = $media; 118 | return $this; 119 | } 120 | 121 | function set_multiMedias($medias) { 122 | $this->multiMedias = $medias; 123 | return $this; 124 | } 125 | } 126 | interface ApnMsg 127 | { 128 | public function get_alertMsg(); 129 | } 130 | 131 | class DictionaryAlertMsg implements ApnMsg{ 132 | 133 | var $title; 134 | var $body; 135 | var $titleLocKey; 136 | var $titleLocArgs = array(); 137 | var $actionLocKey; 138 | var $locKey; 139 | var $locArgs = array(); 140 | var $launchImage; 141 | 142 | public function get_alertMsg() { 143 | 144 | $alertMap = array(); 145 | 146 | if ($this->title != null && $this->title != "") { 147 | $alertMap["title"] = $this->title; 148 | } 149 | if ($this->body != null && $this->body != "") { 150 | $alertMap["body"] = $this->body; 151 | } 152 | if ($this->titleLocKey != null && $this->titleLocKey != "") { 153 | $alertMap["title-loc-key"] = $this->titleLocKey; 154 | } 155 | if (sizeof($this->titleLocArgs) > 0) { 156 | $alertMap["title-loc-args"] = $this->titleLocArgs; 157 | } 158 | if ($this->actionLocKey != null && $this->actionLocKey) { 159 | $alertMap["action-loc-key"] = $this->actionLocKey; 160 | } 161 | if ($this->locKey != null && $this->locKey != "") { 162 | $alertMap["loc-key"] = $this->locKey; 163 | } 164 | if (sizeof($this->locArgs) > 0) { 165 | $alertMap["loc-args"] = $this->locArgs; 166 | } 167 | if ($this->launchImage != null && $this->launchImage != "") { 168 | $alertMap["launch-image"] = $this->launchImage; 169 | } 170 | 171 | if(count($alertMap) == 0) 172 | { 173 | return null; 174 | } 175 | 176 | return $alertMap; 177 | } 178 | } 179 | 180 | class SimpleAlertMsg implements ApnMsg{ 181 | var $alertMsg; 182 | 183 | public function get_alertMsg() { 184 | return $this->alertMsg; 185 | } 186 | } 187 | ?> 188 | -------------------------------------------------------------------------------- /src/getui/igetui/template/IGt.BaseTemplate.php: -------------------------------------------------------------------------------- 1 | set_templateId($this->getTemplateId()); 17 | $transparent->set_id(''); 18 | $transparent->set_messageId(''); 19 | $transparent->set_taskId(''); 20 | $transparent->set_action('pushmessage'); 21 | $transparent->set_pushInfo($this->get_pushInfo()); 22 | $transparent->set_appId($this->appId); 23 | $transparent->set_appKey($this->appkey); 24 | 25 | $actionChainList = $this->getActionChain(); 26 | 27 | foreach ($actionChainList as $index => $actionChain) { 28 | $transparent->add_actionChain(); 29 | $transparent->set_actionChain($index, $actionChain); 30 | } 31 | 32 | $transparent->append_condition($this->get_durcondition()); 33 | 34 | return $transparent->SerializeToString(); 35 | 36 | //return $transparent->condition(0); 37 | } 38 | 39 | function getActionChain() 40 | { 41 | return $list = array(); 42 | } 43 | 44 | function get_durcondition() 45 | { 46 | if ($this->duration == null || $this->duration == '') 47 | { 48 | return ""; 49 | } 50 | return "duration=" . $this->duration; 51 | } 52 | 53 | function get_duration() 54 | { 55 | return $this->duration; 56 | } 57 | 58 | function set_duration($begin, $end) 59 | 60 | { 61 | date_default_timezone_set('asia/shanghai'); 62 | /* //for test 63 | var_dump(date("Y-m-d H:i:s",strtotime($begin))); 64 | var_dump(date("Y-m-d H:i:s",strtotime($end))); 65 | */ 66 | $ss = (string)strtotime($begin) * 1000; 67 | $e = (string)strtotime($end) * 1000; 68 | if ($ss <= 0 || $e <= 0) 69 | throw new Exception("DateFormat: yyyy-MM-dd HH:mm:ss"); 70 | if ($ss > $e) 71 | throw new Exception("startTime should be smaller than endTime"); 72 | 73 | $this->duration = $ss . "-" . $e; 74 | 75 | } 76 | 77 | function get_transmissionContent() 78 | { 79 | return null; 80 | } 81 | 82 | function get_pushType() 83 | { 84 | return null; 85 | } 86 | 87 | function get_actionChain() 88 | { 89 | return null; 90 | } 91 | 92 | function get_pushInfo() 93 | { 94 | if ($this->pushInfo == null) { 95 | $this->pushInfo = new PushInfo(); 96 | $this->pushInfo->set_invalidAPN(true); 97 | $this->pushInfo->set_invalidMPN(true); 98 | } 99 | 100 | return $this->pushInfo; 101 | } 102 | 103 | function set_pushInfo($actionLocKey, $badge, $message, $sound, $payload, $locKey, $locArgs, $launchImage, $contentAvailable = 0) 104 | { 105 | $apn = new IGtAPNPayload(); 106 | 107 | $alertMsg = new DictionaryAlertMsg(); 108 | if ($actionLocKey != null && $actionLocKey != '') 109 | { 110 | $alertMsg->actionLocKey = $actionLocKey; 111 | } 112 | if ($message != null && $message != '') 113 | { 114 | $alertMsg->body = $message; 115 | } 116 | if ($locKey != null && $locKey != '') 117 | { 118 | $alertMsg->locKey = $locKey; 119 | } 120 | if ($locArgs != null && $locArgs != '') 121 | { 122 | array_push($alertMsg->locArgs, $locArgs); 123 | } 124 | 125 | if ($launchImage != null && $launchImage != '') 126 | { 127 | $alertMsg->launchImage = $launchImage; 128 | } 129 | $apn->alertMsg = $alertMsg; 130 | 131 | if ($badge != null ) 132 | { 133 | $apn->badge = $badge; 134 | } 135 | if ($sound != null && $sound != '') 136 | { 137 | $apn->sound = $sound; 138 | } 139 | if ($contentAvailable != null ) 140 | { 141 | $apn->contentAvailable = $contentAvailable; 142 | } 143 | if ($payload != null && $payload != '') 144 | { 145 | $apn->add_customMsg("payload", $payload); 146 | } 147 | $this->set_apnInfo($apn); 148 | } 149 | 150 | function set_apnInfo($payload) 151 | { 152 | if ($payload == null) { 153 | return; 154 | } 155 | $payload = $payload->get_payload(); 156 | if ($payload == null || $payload == "") { 157 | return; 158 | } 159 | $len = strlen($payload); 160 | if ($len > IGtAPNPayload::$PAYLOAD_MAX_BYTES) { 161 | throw new Exception("APN payload length overlength (" . $len . ">" . IGtAPNPayload::$PAYLOAD_MAX_BYTES . ")"); 162 | } 163 | $pushInfo = $this->get_pushInfo(); 164 | $pushInfo->set_apnJson($payload); 165 | $pushInfo->set_invalidAPN(false); 166 | } 167 | 168 | function set_appId($appId) 169 | { 170 | $this->appId = $appId; 171 | } 172 | 173 | function set_appkey($appkey) 174 | { 175 | $this->appkey = $appkey; 176 | } 177 | 178 | function abslength($str) 179 | { 180 | if (empty($str)) { 181 | return 0; 182 | } 183 | if (function_exists('mb_strlen')) { 184 | return mb_strlen($str, 'utf-8'); 185 | } else { 186 | preg_match_all("/./u", $str, $ar); 187 | return count($ar[0]); 188 | } 189 | } 190 | 191 | function getTemplateId() { 192 | if($this instanceof IGtNotificationTemplate) { 193 | return 0; 194 | } 195 | if($this instanceof IGtLinkTemplate) { 196 | return 1; 197 | } 198 | if($this instanceof IGtNotyPopLoadTemplate) { 199 | return 2; 200 | } 201 | if($this instanceof IGtTransmissionTemplate) { 202 | return 4; 203 | } 204 | if($this instanceof IGtAPNTemplate) { 205 | return 5; 206 | } 207 | return -1; 208 | } 209 | 210 | 211 | } -------------------------------------------------------------------------------- /src/getui/igetui/template/IGt.NotyPopLoadTemplate.php: -------------------------------------------------------------------------------- 1 | set_actionId(1); 85 | $actionChain1->set_type(ActionChain_Type::refer); 86 | $actionChain1->set_next(10000); 87 | //通知 88 | $actionChain2 = new ActionChain(); 89 | $actionChain2->set_actionId(10000); 90 | $actionChain2->set_type(ActionChain_Type::mmsinbox2); 91 | $actionChain2->set_stype("notification"); 92 | 93 | $f_text = new InnerFiled(); 94 | $f_text->set_key("text"); 95 | $f_text->set_val($this->notyContent); 96 | $f_text->set_type(InnerFiled_Type::str); 97 | $actionChain2->set_field(0,$f_text); 98 | 99 | $f_title = new InnerFiled(); 100 | $f_title->set_key("title"); 101 | $f_title->set_val($this->notyTitle); 102 | $f_title->set_type(InnerFiled_Type::str); 103 | $actionChain2->set_field(1,$f_title); 104 | 105 | $f_logo = new InnerFiled(); 106 | $f_logo->set_key("logo"); 107 | $f_logo->set_val($this->notyIcon); 108 | $f_logo->set_type(InnerFiled_Type::str); 109 | $actionChain2->set_field(2,$f_logo); 110 | 111 | $f_logoURL = new InnerFiled(); 112 | $f_logoURL->set_key("logo_url"); 113 | $f_logoURL->set_val($this->logoURL); 114 | $f_logoURL->set_type(InnerFiled_Type::str); 115 | $actionChain2->set_field(3,$f_logoURL); 116 | 117 | $f_notifyStyle = new InnerFiled(); 118 | $f_notifyStyle->set_key("notifyStyle"); 119 | $f_notifyStyle->set_val(strval($this->notifyStyle)); 120 | $f_notifyStyle->set_type(InnerFiled_Type::str); 121 | $actionChain2->set_field(4,$f_notifyStyle); 122 | 123 | $f_isRing = new InnerFiled(); 124 | $f_isRing->set_key("is_noring"); 125 | $f_isRing->set_val(!$this->isBelled ? "true" : "false"); 126 | $f_isRing->set_type(InnerFiled_Type::bool); 127 | $actionChain2->set_field(5,$f_isRing); 128 | 129 | $f_isVibrate = new InnerFiled(); 130 | $f_isVibrate->set_key("is_novibrate"); 131 | $f_isVibrate->set_val(!$this->isVibrationed ? "true" : "false"); 132 | $f_isVibrate->set_type(InnerFiled_Type::bool); 133 | $actionChain2->set_field(6,$f_isVibrate); 134 | 135 | $f_isClearable = new InnerFiled(); 136 | $f_isClearable->set_key("is_noclear"); 137 | $f_isClearable->set_val(!$this->isCleared ? "true" : "false"); 138 | $f_isClearable->set_type(InnerFiled_Type::bool); 139 | $actionChain2->set_field(7,$f_isClearable); 140 | 141 | $actionChain2->set_next(10010); 142 | 143 | $actionChain3 = new ActionChain(); 144 | $actionChain3->set_actionId(10010); 145 | $actionChain3->set_type(ActionChain_Type::refer); 146 | $actionChain3->set_next(10020); 147 | 148 | //弹框按钮 149 | $button1 = new Button(); 150 | $button1->set_text($this->popButton1); 151 | $button1->set_next(10050); 152 | $button2 = new Button(); 153 | $button2->set_text($this->popButton2); 154 | $button2->set_next(100); 155 | 156 | //弹框 157 | $actionChain4 = new ActionChain(); 158 | $actionChain4->set_actionId(10020); 159 | $actionChain4->set_type(ActionChain_Type::popup); 160 | $actionChain4->set_title($this->popTitle); 161 | $actionChain4->set_text($this->popContent); 162 | $actionChain4->set_img($this->popImage); 163 | $actionChain4->set_buttons(0,$button1); 164 | $actionChain4->set_buttons(1,$button2); 165 | $actionChain4->set_next(6); 166 | 167 | //下载 168 | //appstartupid 169 | $appStartUp = new AppStartUp(); 170 | $appStartUp->set_android($this->androidMark); 171 | $appStartUp->set_Ios($this->iosMark); 172 | $appStartUp->set_symbia($this->symbianMark); 173 | $actionChain5 = new ActionChain(); 174 | $actionChain5->set_actionId(10050); 175 | $actionChain5->set_type(ActionChain_Type::appdownload); 176 | $actionChain5->set_name($this->loadTitle); 177 | $actionChain5->set_url($this->loadUrl); 178 | $actionChain5->set_logo($this->loadIcon); 179 | $actionChain5->set_autoInstall($this->isAutoInstall); 180 | $actionChain5->set_autostart($this->isActived); 181 | $actionChain5->set_appstartupid($appStartUp); 182 | $actionChain5->set_next(6); 183 | 184 | $actionChain6 = new ActionChain(); 185 | $actionChain6->set_actionId(100); 186 | $actionChain6->set_type(ActionChain_Type::eoa); 187 | 188 | array_push($actionChains, $actionChain1,$actionChain2,$actionChain3,$actionChain4,$actionChain5,$actionChain6); 189 | return $actionChains; 190 | } 191 | 192 | function set_notyIcon($notyIcon) { 193 | $this->notyIcon = $notyIcon; 194 | } 195 | function set_notyTitle($notyTitle) { 196 | $this->notyTitle = $notyTitle; 197 | } 198 | function set_logoURL($logoURL) { 199 | $this->logoURL = $logoURL; 200 | } 201 | function set_notyContent($notyContent) { 202 | $this->notyContent = $notyContent; 203 | } 204 | function set_isCleared($isCleared) { 205 | $this->isCleared = $isCleared; 206 | } 207 | function set_isBelled($isBelled) { 208 | $this->isBelled = $isBelled; 209 | } 210 | function set_isVibrationed($isVibrationed) { 211 | $this->isVibrationed = $isVibrationed; 212 | } 213 | function set_popTitle($popTitle) { 214 | $this->popTitle = $popTitle; 215 | } 216 | function set_popContent($popContent) { 217 | $this->popContent = $popContent; 218 | } 219 | function set_popImage($popImage) { 220 | $this->popImage = $popImage; 221 | } 222 | function set_popButton1($popButton1) { 223 | $this->popButton1 = $popButton1; 224 | } 225 | function set_popButton2($popButton2) { 226 | $this->popButton2 = $popButton2; 227 | } 228 | function set_loadIcon($loadIcon) { 229 | $this->loadIcon = $loadIcon; 230 | } 231 | function set_loadTitle($loadTitle) { 232 | $this->loadTitle = $loadTitle; 233 | } 234 | function set_loadUrl($loadUrl) { 235 | $this->loadUrl = $loadUrl; 236 | } 237 | function set_isAutoInstall($isAutoInstall) { 238 | $this->isAutoInstall = $isAutoInstall; 239 | } 240 | function set_isActived($isActived) { 241 | $this->isActived = $isActived; 242 | } 243 | function set_symbianMark($symbianMark){ 244 | $this->symbianMark = $symbianMark; 245 | } 246 | function set_androidMark($androidMark){ 247 | $this->androidMark = $androidMark; 248 | } 249 | function set_iosMark($iosMark){ 250 | $this->iosMark = $iosMark; 251 | } 252 | function get_pushType(){ 253 | return "NotyPopLoadTemplate"; 254 | } 255 | 256 | function set_notifyStyle($notifyStyle) { 257 | if($notifyStyle != 1){ 258 | $this->notifyStyle = 0; 259 | } else { 260 | $this->notifyStyle = 1; 261 | } 262 | } 263 | } -------------------------------------------------------------------------------- /src/getui/alias_demo.php: -------------------------------------------------------------------------------- 1 | bindAlias(APPID,ALIAS,CID); 39 | var_dump($rep); 40 | echo("

"); 41 | 42 | } 43 | 44 | function aliasBatch(){ 45 | 46 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET); 47 | 48 | $target = new IGtTarget(); 49 | $target->set_clientId(CID); 50 | $target->set_alias(ALIAS); 51 | $targetList[] = $target; 52 | 53 | // $target1 = new IGtTarget(); 54 | // $target1->set_clientId(CID2); 55 | // $target1->set_alias(ALIAS); 56 | // $targetList[] = $target1; 57 | 58 | $rep = $igt->bindAliasBatch(APPID,$targetList); 59 | var_dump($rep); 60 | echo("

"); 61 | } 62 | 63 | function queryCID(){ 64 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET); 65 | $rep = $igt->queryClientId(APPID,ALIAS); 66 | var_dump($rep); 67 | echo("

"); 68 | } 69 | 70 | function queryAlias(){ 71 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET); 72 | $rep = $igt->queryAlias(APPID,CID); 73 | var_dump($rep); 74 | echo("

"); 75 | } 76 | 77 | function aliasUnBind(){ 78 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET); 79 | $rep = $igt->unBindAlias(APPID,ALIAS,CID); 80 | var_dump($rep); 81 | echo("

"); 82 | } 83 | 84 | function aliasUnBindAll(){ 85 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET); 86 | $rep = $igt->unBindAliasAll(APPID,ALIAS,CID); 87 | var_dump($rep); 88 | echo("

"); 89 | } 90 | 91 | // 92 | //服务端推送接口,支持三个接口推送 93 | //1.PushMessageToSingle接口:支持对单个用户进行推送 94 | //2.PushMessageToList接口:支持对多个用户进行推送,建议为50个用户 95 | //3.pushMessageToApp接口:对单个应用下的所有用户进行推送,可根据省份,标签,机型过滤推送 96 | // 97 | 98 | //单推接口案例 99 | function pushMessageToSingle(){ 100 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET); 101 | 102 | //消息模版: 103 | // 1.TransmissionTemplate:透传功能模板 104 | // 2.LinkTemplate:通知打开链接功能模板 105 | // 3.NotificationTemplate:通知透传功能模板 106 | // 4.NotyPopLoadTemplate:通知弹框下载功能模板 107 | 108 | //$template = IGtNotyPopLoadTemplateDemo(); 109 | //$template = IGtLinkTemplateDemo(); 110 | //$template = IGtNotificationTemplateDemo(); 111 | $template = IGtTransmissionTemplateDemo(); 112 | 113 | //个推信息体 114 | $message = new IGtSingleMessage(); 115 | 116 | $message->set_isOffline(true);//是否离线 117 | $message->set_offlineExpireTime(3600*12*1000);//离线时间 118 | $message->set_data($template);//设置推送消息类型 119 | $message->set_PushNetWorkType(0);//设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送 120 | //接收方 121 | $target = new IGtTarget(); 122 | $target->set_appId(APPID); 123 | //$target->set_clientId(CID); 124 | $target->set_alias(ALIAS); 125 | 126 | $rep = $igt->pushMessageToSingle($message,$target); 127 | 128 | var_dump($rep); 129 | echo ("

"); 130 | } 131 | 132 | 133 | //多推接口案例 134 | function pushMessageToList(){ 135 | putenv("needDetails=true"); 136 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET); 137 | //消息模版: 138 | // 1.TransmissionTemplate:透传功能模板 139 | // 2.LinkTemplate:通知打开链接功能模板 140 | // 3.NotificationTemplate:通知透传功能模板 141 | // 4.NotyPopLoadTemplate:通知弹框下载功能模板 142 | 143 | 144 | //$template = IGtNotyPopLoadTemplateDemo(); 145 | //$template = IGtLinkTemplateDemo(); 146 | //$template = IGtNotificationTemplateDemo(); 147 | $template = IGtTransmissionTemplateDemo(); 148 | //个推信息体 149 | $message = new IGtListMessage(); 150 | 151 | $message->set_isOffline(true);//是否离线 152 | $message->set_offlineExpireTime(3600*12*1000);//离线时间 153 | $message->set_data($template);//设置推送消息类型 154 | //$message->set_PushNetWorkType(0); //设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送 155 | $contentId = $igt->getContentId($message,'toList'); 156 | //$contentId = $igt->getContentId($message,"toList任务别名功能"); //根据TaskId设置组名,支持下划线,中文,英文,数字 157 | 158 | //接收方1 159 | $target1 = new IGtTarget(); 160 | $target1->set_appId(APPID); 161 | //$target1->set_clientId(CID); 162 | $target1->set_alias(ALIAS); 163 | 164 | $targetList[] = $target1; 165 | 166 | $rep = $igt->pushMessageToList($contentId, $targetList); 167 | 168 | var_dump($rep); 169 | echo ("

"); 170 | 171 | } 172 | 173 | //所有推送接口均支持四个消息模板,依次为通知弹框下载模板,通知链接模板,通知透传模板,透传模板 174 | //注:IOS离线推送需通过APN进行转发,需填写pushInfo字段,目前仅不支持通知弹框下载功能 175 | 176 | function IGtNotyPopLoadTemplateDemo(){ 177 | $template = new IGtNotyPopLoadTemplate(); 178 | 179 | $template ->set_appId(APPID);//应用appid 180 | $template ->set_appkey(APPKEY);//应用appkey 181 | //通知栏 182 | $template ->set_notyTitle("个推");//通知栏标题 183 | $template ->set_notyContent("个推最新版点击下载");//通知栏内容 184 | $template ->set_notyIcon("");//通知栏logo 185 | $template ->set_isBelled(true);//是否响铃 186 | $template ->set_isVibrationed(true);//是否震动 187 | $template ->set_isCleared(true);//通知栏是否可清除 188 | //弹框 189 | $template ->set_popTitle("弹框标题");//弹框标题 190 | $template ->set_popContent("弹框内容");//弹框内容 191 | $template ->set_popImage("");//弹框图片 192 | $template ->set_popButton1("下载");//左键 193 | $template ->set_popButton2("取消");//右键 194 | //下载 195 | $template ->set_loadIcon("");//弹框图片 196 | $template ->set_loadTitle("地震速报下载"); 197 | $template ->set_loadUrl("http://dizhensubao.igexin.com/dl/com.ceic.apk"); 198 | $template ->set_isAutoInstall(false); 199 | $template ->set_isActived(true); 200 | 201 | return $template; 202 | } 203 | 204 | function IGtLinkTemplateDemo(){ 205 | $template = new IGtLinkTemplate(); 206 | $template ->set_appId(APPID);//应用appid 207 | $template ->set_appkey(APPKEY);//应用appkey 208 | $template ->set_title("请输入通知标题");//通知栏标题 209 | $template ->set_text("请输入通知内容");//通知栏内容 210 | $template ->set_logo("");//通知栏logo 211 | $template ->set_isRing(true);//是否响铃 212 | $template ->set_isVibrate(true);//是否震动 213 | $template ->set_isClearable(true);//通知栏是否可清除 214 | $template ->set_url("http://www.igetui.com/");//打开连接地址 215 | // iOS推送需要设置的pushInfo字段 216 | //$template ->set_pushInfo($actionLocKey,$badge,$message,$sound,$payload,$locKey,$locArgs,$launchImage); 217 | //$template ->set_pushInfo("",2,"","","","","",""); 218 | return $template; 219 | } 220 | 221 | function IGtNotificationTemplateDemo(){ 222 | $template = new IGtNotificationTemplate(); 223 | $template->set_appId(APPID);//应用appid 224 | $template->set_appkey(APPKEY);//应用appkey 225 | $template->set_transmissionType(1);//透传消息类型 226 | $template->set_transmissionContent("测试离线");//透传内容 227 | $template->set_title("个推");//通知栏标题 228 | $template->set_text("个推最新版点击下载");//通知栏内容 229 | $template->set_logo("http://wwww.igetui.com/logo.png");//通知栏logo 230 | $template->set_isRing(true);//是否响铃 231 | $template->set_isVibrate(true);//是否震动 232 | $template->set_isClearable(true);//通知栏是否可清除 233 | // iOS推送需要设置的pushInfo字段 234 | //$template ->set_pushInfo($actionLocKey,$badge,$message,$sound,$payload,$locKey,$locArgs,$launchImage); 235 | //$template ->set_pushInfo("test",1,"message","","","","",""); 236 | return $template; 237 | } 238 | 239 | function IGtTransmissionTemplateDemo(){ 240 | $template = new IGtTransmissionTemplate(); 241 | $template->set_appId(APPID);//应用appid 242 | $template->set_appkey(APPKEY);//应用appkey 243 | $template->set_transmissionType(1);//透传消息类型 244 | $template->set_transmissionContent("测试离线");//透传内容 245 | //iOS推送需要设置的pushInfo字段 246 | //$template ->set_pushInfo($actionLocKey,$badge,$message,$sound,$payload,$locKey,$locArgs,$launchImage); 247 | //$template ->set_pushInfo("", 0, "", "", "", "", "", ""); 248 | return $template; 249 | } 250 | 251 | 252 | 253 | ?> 254 | -------------------------------------------------------------------------------- /src/getui/igetui/utils/ApnsUtils.php: -------------------------------------------------------------------------------- 1 | 0) { 22 | // loc-key 23 | $pb->setAlertLocKey(($locKey)); 24 | // loc-args 25 | if ($locArgs != null && strlen($locArgs) > 0) { 26 | $pb->setAlertLocArgs(explode(',',($locArgs))); 27 | } 28 | $isValid = true; 29 | } 30 | 31 | // body 32 | if ($message != null && strlen($message) > 0) { 33 | $pb->setAlertBody(($message)); 34 | $isValid = true; 35 | } 36 | 37 | // action-loc-key 38 | if ($actionLocKey!=null && strlen($actionLocKey) > 0) { 39 | $pb->setAlertActionLocKey($actionLocKey); 40 | } 41 | 42 | // launch-image 43 | if ($launchImage!=null && strlen($launchImage) > 0) { 44 | $pb->setAlertLaunchImage($launchImage); 45 | } 46 | 47 | // badge 48 | $badgeNum = -1; 49 | if(is_numeric($badge)){ 50 | $badgeNum = (int)$badge; 51 | } 52 | if ($badgeNum >= 0) { 53 | $pb->setBadge($badgeNum); 54 | $isValid = true; 55 | } 56 | 57 | // sound 58 | if ($sound != null && strlen($sound) > 0) { 59 | $pb->setSound($sound); 60 | } else { 61 | $pb->setSound("default"); 62 | } 63 | 64 | //contentAvailable 65 | if ($contentAvailable == 1) { 66 | $pb->setContentAvailable(1); 67 | $isValid = true; 68 | } 69 | 70 | // payload 71 | if ($payload != null && strlen($payload) > 0) { 72 | $pb->addParam("payload", ($payload)); 73 | } 74 | 75 | if($isValid == false){ 76 | throw new Exception("one of the params(locKey,message,badge) must not be null or contentAvailable must be 1"); 77 | } 78 | $json = $pb->toString(); 79 | if($json == null){ 80 | throw new Exception("payload json is null"); 81 | } 82 | return $json; 83 | } 84 | } 85 | 86 | Class Payload 87 | { 88 | var $APS = "aps"; 89 | var $params; 90 | var $alert; 91 | var $badge; 92 | var $sound = ""; 93 | 94 | var $alertBody; 95 | var $alertActionLocKey; 96 | var $alertLocKey; 97 | var $alertLocArgs; 98 | var $alertLaunchImage; 99 | var $contentAvailable; 100 | 101 | function getParams() 102 | { 103 | return $this->params; 104 | } 105 | 106 | function setParams($params) 107 | { 108 | $this->params = $params; 109 | } 110 | 111 | function addParam($key, $obj) 112 | { 113 | if ($this->params == null) { 114 | $this->params = array(); 115 | } 116 | if ($this->APS == strtolower($key)) { 117 | throw new Exception("the key can't be aps"); 118 | } 119 | $this->params[$key] = $obj; 120 | } 121 | 122 | function getAlert() 123 | { 124 | return $this->alert; 125 | } 126 | 127 | function setAlert($alert) 128 | { 129 | $this->alert = $alert; 130 | } 131 | 132 | function getBadge() 133 | { 134 | return $this->badge; 135 | } 136 | 137 | function setBadge($badge) 138 | { 139 | $this->badge = $badge; 140 | } 141 | 142 | function getSound() 143 | { 144 | return $this->sound; 145 | } 146 | 147 | function setSound($sound) 148 | { 149 | $this->sound = $sound; 150 | } 151 | 152 | function getAlertBody() 153 | { 154 | return $this->alertBody; 155 | } 156 | 157 | function setAlertBody($alertBody) 158 | { 159 | $this->alertBody = $alertBody; 160 | } 161 | 162 | function getAlertActionLocKey() 163 | { 164 | return $this->alertActionLocKey; 165 | } 166 | 167 | function setAlertActionLocKey($alertActionLocKey) 168 | { 169 | $this->alertActionLocKey = $alertActionLocKey; 170 | } 171 | 172 | function getAlertLocKey() 173 | { 174 | return $this->alertLocKey; 175 | } 176 | 177 | function setAlertLocKey($alertLocKey) 178 | { 179 | $this->alertLocKey = $alertLocKey; 180 | } 181 | 182 | function getAlertLaunchImage() 183 | { 184 | return $this->alertLaunchImage; 185 | } 186 | 187 | function setAlertLaunchImage($alertLaunchImage) 188 | { 189 | $this->alertLaunchImage = $alertLaunchImage; 190 | } 191 | 192 | function getAlertLocArgs() 193 | { 194 | return $this->alertLocArgs; 195 | } 196 | 197 | function setAlertLocArgs($alertLocArgs) 198 | { 199 | $this->alertLocArgs = $alertLocArgs; 200 | } 201 | 202 | function getContentAvailable() 203 | { 204 | return $this->contentAvailable; 205 | } 206 | 207 | function setContentAvailable($contentAvailable) 208 | { 209 | $this->contentAvailable = $contentAvailable; 210 | } 211 | 212 | function putIntoJson($key, $value, $obj) 213 | { 214 | if ($value != null) { 215 | $obj[$key] = $value; 216 | } 217 | return $obj; 218 | } 219 | 220 | function toString() 221 | { 222 | $object = array(); 223 | $apsObj = array(); 224 | if ($this->getAlert() != null) { 225 | $apsObj["alert"] = urlencode($this->getAlert()); 226 | } else { 227 | if ($this->getAlertBody() != null || $this->getAlertLocKey() != null) { 228 | $alertObj = array(); 229 | $alertObj = $this->putIntoJson("body", ($this->getAlertBody()), $alertObj); 230 | $alertObj = $this->putIntoJson("action-loc-key", ($this->getAlertActionLocKey()), $alertObj); 231 | $alertObj = $this->putIntoJson("loc-key", ($this->getAlertLocKey()), $alertObj); 232 | $alertObj = $this->putIntoJson("launch-image", ($this->getAlertLaunchImage()), $alertObj); 233 | if ($this->getAlertLocArgs() != null) { 234 | $array = array(); 235 | foreach ($this->getAlertLocArgs() as $str) { 236 | array_push($array, ($str)); 237 | } 238 | $alertObj["loc-args"] = $array; 239 | } 240 | $apsObj["alert"] = $alertObj; 241 | } 242 | } 243 | if ($this->getBadge() != null) { 244 | $apsObj["badge"] = $this->getBadge(); 245 | } 246 | // 判断是否静音 247 | if ("com.gexin.ios.silence" != ($this->getSound())) { 248 | $apsObj = $this->putIntoJson("sound", ($this->getSound()), $apsObj); 249 | } 250 | if($this->getContentAvailable() == 1){ 251 | $apsObj["content-available"]=1; 252 | } 253 | $object[$this->APS] = $apsObj; 254 | if ($this->getParams() != null) { 255 | foreach ($this->getParams() as $key => $value) { 256 | $object[($key)] = ($value); 257 | } 258 | } 259 | return Util::json_encode($object); 260 | } 261 | } 262 | 263 | class Util 264 | { 265 | static function json_encode($input){ 266 | // 从 PHP 5.4.0 起, 增加了这个选项. 267 | if(defined('JSON_UNESCAPED_UNICODE')){ 268 | return json_encode($input, JSON_UNESCAPED_UNICODE); 269 | } 270 | if(is_string($input)){ 271 | $text = $input; 272 | $text = str_replace("\\", "\\\\", $text); 273 | //$text = str_replace('/', "\\/", $text); 274 | $text = str_replace('"', "\\".'"', $text); 275 | $text = str_replace("\b", "\\b", $text); 276 | $text = str_replace("\t", "\\t", $text); 277 | $text = str_replace("\n", "\\n", $text); 278 | $text = str_replace("\f", "\\f", $text); 279 | $text = str_replace("\r", "\\r", $text); 280 | //$text = str_replace("\u", "\\u", $text); 281 | return '"' . $text . '"'; 282 | } else if(is_array($input) || is_object($input)) { 283 | $arr = array(); 284 | $is_obj = is_object($input) || (array_keys($input) !== range(0, count($input) - 1)); 285 | foreach($input as $k=>$v){ 286 | if($is_obj){ 287 | $arr[] = self::json_encode($k) . ':' . self::json_encode($v); 288 | }else{ 289 | $arr[] = self::json_encode($v); 290 | } 291 | } 292 | if($is_obj){ 293 | return '{' . join(',', $arr) . '}'; 294 | }else{ 295 | return '[' . join(',', $arr) . ']'; 296 | } 297 | }else{ 298 | return $input . ''; 299 | } 300 | } 301 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /src/getui/protobuf/pb_message.php: -------------------------------------------------------------------------------- 1 | reader = $reader; 62 | $this->value = $this; 63 | $this->base128 = new base128varint(PBMessage::MODUS); 64 | } 65 | 66 | /** 67 | * Get the wired_type and field_type 68 | * @param $number as decimal 69 | * @return array wired_type, field_type 70 | */ 71 | public function get_types($number) 72 | { 73 | $binstring = decbin($number); 74 | $types = array(); 75 | $low = substr($binstring, strlen($binstring) - 3, strlen($binstring)); 76 | $high = substr($binstring,0, strlen($binstring) - 3) . '0000'; 77 | $types['wired'] = bindec($low); 78 | $types['field'] = bindec($binstring) >> 3; 79 | return $types; 80 | } 81 | 82 | 83 | /** 84 | * Encodes a Message 85 | * @return string the encoded message 86 | */ 87 | public function SerializeToString($rec=-1) 88 | { 89 | $string = ''; 90 | // wired and type 91 | if ($rec > -1) 92 | { 93 | $string .= $this->base128->set_value($rec << 3 | $this->wired_type); 94 | } 95 | 96 | $stringinner = ''; 97 | 98 | foreach ($this->fields as $index => $field) 99 | { 100 | if (is_array($this->values[$index]) && count($this->values[$index]) > 0) 101 | { 102 | // make serialization for every array 103 | foreach ($this->values[$index] as $array) 104 | { 105 | $newstring = ''; 106 | $newstring .= $array->SerializeToString($index); 107 | 108 | $stringinner .= $newstring; 109 | } 110 | } 111 | else if ($this->values[$index] != null) 112 | { 113 | // wired and type 114 | $newstring = ''; 115 | $newstring .= $this->values[$index]->SerializeToString($index); 116 | 117 | $stringinner .= $newstring; 118 | } 119 | } 120 | 121 | $this->_serialize_chunk($stringinner); 122 | 123 | if ($this->wired_type == PBMessage::WIRED_LENGTH_DELIMITED && $rec > -1) 124 | { 125 | $stringinner = $this->base128->set_value(strlen($stringinner) / PBMessage::MODUS) . $stringinner; 126 | } 127 | 128 | return $string . $stringinner; 129 | } 130 | 131 | /** 132 | * Serializes the chunk 133 | * @param String $stringinner - String where to append the chunk 134 | */ 135 | public function _serialize_chunk(&$stringinner) 136 | { 137 | $stringinner .= $this->chunk; 138 | } 139 | 140 | /** 141 | * Decodes a Message and Built its things 142 | * 143 | * @param message as stream of hex example '1a 03 08 96 01' 144 | */ 145 | public function ParseFromString($message) 146 | { 147 | $this->reader = new PBInputStringReader($message); 148 | $this->_ParseFromArray(); 149 | } 150 | 151 | /** 152 | * Internal function 153 | */ 154 | public function ParseFromArray() 155 | { 156 | $this->chunk = ''; 157 | // read the length byte 158 | $length = $this->reader->next(); 159 | // just take the splice from this array 160 | $this->_ParseFromArray($length); 161 | } 162 | 163 | /** 164 | * Internal function 165 | */ 166 | private function _ParseFromArray($length=99999999) 167 | { 168 | $_begin = $this->reader->get_pointer(); 169 | while ($this->reader->get_pointer() - $_begin < $length) 170 | { 171 | $next = $this->reader->next(); 172 | if ($next === false) 173 | break; 174 | 175 | // now get the message type 176 | $messtypes = $this->get_types($next); 177 | 178 | // now make method test 179 | if (!isset($this->fields[$messtypes['field']])) 180 | { 181 | // field is unknown so just ignore it 182 | // throw new Exception('Field ' . $messtypes['field'] . ' not present '); 183 | if ($messtypes['wired'] == PBMessage::WIRED_LENGTH_DELIMITED) 184 | { 185 | $consume = new PBString($this->reader); 186 | } 187 | else if ($messtypes['wired'] == PBMessage::WIRED_VARINT) 188 | { 189 | $consume = new PBInt($this->reader); 190 | } 191 | else 192 | { 193 | throw new Exception('I dont understand this wired code:' . $messtypes['wired']); 194 | } 195 | 196 | // perhaps send a warning out 197 | // @TODO SEND CHUNK WARNING 198 | $_oldpointer = $this->reader->get_pointer(); 199 | $consume->ParseFromArray(); 200 | // now add array from _oldpointer to pointer to the chunk array 201 | $this->chunk .= $this->reader->get_message_from($_oldpointer); 202 | continue; 203 | } 204 | 205 | // now array or not 206 | if (is_array($this->values[$messtypes['field']])) 207 | { 208 | $this->values[$messtypes['field']][] = new $this->fields[$messtypes['field']]($this->reader); 209 | $index = count($this->values[$messtypes['field']]) - 1; 210 | if ($messtypes['wired'] != $this->values[$messtypes['field']][$index]->wired_type) 211 | { 212 | throw new Exception('Expected type:' . $messtypes['wired'] . ' but had ' . $this->fields[$messtypes['field']]->wired_type); 213 | } 214 | $this->values[$messtypes['field']][$index]->ParseFromArray(); 215 | } 216 | else 217 | { 218 | $this->values[$messtypes['field']] = new $this->fields[$messtypes['field']]($this->reader); 219 | if ($messtypes['wired'] != $this->values[$messtypes['field']]->wired_type) 220 | { 221 | throw new Exception('Expected type:' . $messtypes['wired'] . ' but had ' . $this->fields[$messtypes['field']]->wired_type); 222 | } 223 | $this->values[$messtypes['field']]->ParseFromArray(); 224 | } 225 | } 226 | } 227 | 228 | /** 229 | * Add an array value 230 | * @param int - index of the field 231 | */ 232 | protected function _add_arr_value($index) 233 | { 234 | return $this->values[$index][] = new $this->fields[$index](); 235 | } 236 | 237 | /** 238 | * Set an array value - @TODO failure check 239 | * @param int - index of the field 240 | * @param int - index of the array 241 | * @param object - the value 242 | */ 243 | protected function _set_arr_value($index, $index_arr, $value) 244 | { 245 | $this->values[$index][$index_arr] = $value; 246 | } 247 | 248 | /** 249 | * Remove the last array value 250 | * @param int - index of the field 251 | */ 252 | protected function _remove_last_arr_value($index) 253 | { 254 | array_pop($this->values[$index]); 255 | } 256 | 257 | /** 258 | * Set an value 259 | * @param int - index of the field 260 | * @param Mixed value 261 | */ 262 | protected function _set_value($index, $value) 263 | { 264 | if (gettype($value) == 'object') 265 | { 266 | $this->values[$index] = $value; 267 | } 268 | else 269 | { 270 | $this->values[$index] = new $this->fields[$index](); 271 | $this->values[$index]->value = $value; 272 | } 273 | } 274 | 275 | /** 276 | * Get a value 277 | * @param id of the field 278 | */ 279 | protected function _get_value($index) 280 | { 281 | if ($this->values[$index] == null) 282 | return null; 283 | return $this->values[$index]->value; 284 | } 285 | 286 | /** 287 | * Get array value 288 | * @param id of the field 289 | * @param value 290 | */ 291 | protected function _get_arr_value($index, $value) 292 | { 293 | return $this->values[$index][$value]; 294 | } 295 | 296 | /** 297 | * Get array size 298 | * @param id of the field 299 | */ 300 | protected function _get_arr_size($index) 301 | { 302 | return count($this->values[$index]); 303 | } 304 | 305 | /** 306 | * Helper method for send string 307 | */ 308 | protected function _save_string($ch, $string) 309 | { 310 | $this->_d_string .= $string; 311 | $content_length = strlen($this->_d_string); 312 | return strlen($string); 313 | } 314 | 315 | /** 316 | * Sends the message via post request ['message'] to the url 317 | * @param the url 318 | * @param the PBMessage class where the request should be encoded 319 | * 320 | * @return String - the return string from the request to the url 321 | */ 322 | public function Send($url, &$class = null) 323 | { 324 | $ch = curl_init(); 325 | $this->_d_string = ''; 326 | 327 | curl_setopt($ch, CURLOPT_URL, $url); 328 | curl_setopt($ch, CURLOPT_POST, true); 329 | curl_setopt($ch, CURLOPT_WRITEFUNCTION, array($this, '_save_string')); 330 | curl_setopt($ch, CURLOPT_POSTFIELDS, 'message=' . urlencode($this->SerializeToString())); 331 | $result = curl_exec($ch); 332 | 333 | if ($class != null) 334 | $class->parseFromString($this->_d_string); 335 | return $this->_d_string; 336 | } 337 | 338 | /** 339 | * Fix Memory Leaks with Objects in PHP 5 340 | * http://paul-m-jones.com/?p=262 341 | * 342 | * thanks to cheton 343 | * http://code.google.com/p/pb4php/issues/detail?id=3&can=1 344 | */ 345 | public function _destruct() 346 | { 347 | if (isset($this->reader)) 348 | { 349 | unset($this->reader); 350 | } 351 | if (isset($this->value)) 352 | { 353 | unset($this->value); 354 | } 355 | // base128 356 | if (isset($this->base128)) 357 | { 358 | unset($this->base128); 359 | } 360 | // fields 361 | if (isset($this->fields)) 362 | { 363 | foreach ($this->fields as $name => $value) 364 | { 365 | unset($this->$name); 366 | } 367 | unset($this->fields); 368 | } 369 | // values 370 | if (isset($this->values)) 371 | { 372 | foreach ($this->values as $name => $value) 373 | { 374 | if (is_array($value)) 375 | { 376 | foreach ($value as $name2 => $value2) 377 | { 378 | if (is_object($value2) AND method_exists($value2, '__destruct')) 379 | { 380 | $value2->__destruct(); 381 | } 382 | unset($value2); 383 | } 384 | if (isset($name2)) 385 | unset($value->$name2); 386 | } 387 | else 388 | { 389 | if (is_object($value) AND method_exists($value, '__destruct')) 390 | { 391 | $value->__destruct(); 392 | } 393 | unset($value); 394 | } 395 | unset($this->values->$name); 396 | } 397 | unset($this->values); 398 | } 399 | } 400 | 401 | } 402 | ?> 403 | -------------------------------------------------------------------------------- /src/getui/demo.php: -------------------------------------------------------------------------------- 1 | getPersonaTags(APPID); 55 | var_dump($ret); 56 | } 57 | 58 | function getUserCountByTagsDemo() { 59 | $igt = new IGeTui(HOST, APPKEY, MASTERSECRET); 60 | $tagList = array("金在中","龙卷风"); 61 | $ret = $igt->getUserCountByTags(APPID, $tagList); 62 | var_dump($ret); 63 | } 64 | 65 | function getPushMessageResultDemo(){ 66 | 67 | 68 | // putenv("gexin_default_domainurl=http://183.129.161.174:8006/apiex.htm"); 69 | 70 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET); 71 | 72 | $ret = $igt->getPushResult("OSA-0522_QZ7nHpBlxF6vrxGaLb1FA3"); 73 | var_dump($ret); 74 | 75 | $ret = $igt->queryAppUserDataByDate(APPID,"20140807"); 76 | var_dump($ret); 77 | 78 | $ret = $igt->queryAppPushDataByDate(APPID,"20140807"); 79 | var_dump($ret); 80 | } 81 | 82 | 83 | //用户状态查询 84 | function getUserStatus() { 85 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET); 86 | $rep = $igt->getClientIdStatus(APPID,CID); 87 | var_dump($rep); 88 | echo ("

"); 89 | } 90 | 91 | //推送任务停止 92 | function stoptask(){ 93 | 94 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET); 95 | $igt->stop("OSA-1127_QYZyBzTPWz5ioFAixENzs3"); 96 | } 97 | 98 | //通过服务端设置ClientId的标签 99 | function setTag(){ 100 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET); 101 | $tagList = array('','中文','English'); 102 | $rep = $igt->setClientTag(APPID,CID,$tagList); 103 | var_dump($rep); 104 | echo ("

"); 105 | } 106 | 107 | function getUserTags() { 108 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET); 109 | $rep = $igt->getUserTags(APPID,CID); 110 | //$rep.connect(); 111 | var_dump($rep); 112 | echo ("

"); 113 | } 114 | 115 | // 116 | //服务端推送接口,支持三个接口推送 117 | //1.PushMessageToSingle接口:支持对单个用户进行推送 118 | //2.PushMessageToList接口:支持对多个用户进行推送,建议为50个用户 119 | //3.pushMessageToApp接口:对单个应用下的所有用户进行推送,可根据省份,标签,机型过滤推送 120 | // 121 | 122 | //单推接口案例 123 | function pushMessageToSingle(){ 124 | //$igt = new IGeTui(HOST,APPKEY,MASTERSECRET); 125 | $igt = new IGeTui(NULL,APPKEY,MASTERSECRET,false); 126 | 127 | //消息模版: 128 | // 1.TransmissionTemplate:透传功能模板 129 | // 2.LinkTemplate:通知打开链接功能模板 130 | // 3.NotificationTemplate:通知透传功能模板 131 | // 4.NotyPopLoadTemplate:通知弹框下载功能模板 132 | 133 | // $template = IGtNotyPopLoadTemplateDemo(); 134 | // $template = IGtLinkTemplateDemo(); 135 | // $template = IGtNotificationTemplateDemo(); 136 | $template = IGtTransmissionTemplateDemo(); 137 | 138 | //个推信息体 139 | $message = new IGtSingleMessage(); 140 | 141 | $message->set_isOffline(true);//是否离线 142 | $message->set_offlineExpireTime(3600*12*1000);//离线时间 143 | $message->set_data($template);//设置推送消息类型 144 | // $message->set_PushNetWorkType(0);//设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送 145 | //接收方 146 | $target = new IGtTarget(); 147 | $target->set_appId(APPID); 148 | $target->set_clientId(CID); 149 | // $target->set_alias(Alias); 150 | 151 | 152 | try { 153 | $rep = $igt->pushMessageToSingle($message, $target); 154 | var_dump($rep); 155 | echo ("

"); 156 | 157 | }catch(RequestException $e){ 158 | $requstId =e.getRequestId(); 159 | $rep = $igt->pushMessageToSingle($message, $target,$requstId); 160 | var_dump($rep); 161 | echo ("

"); 162 | } 163 | 164 | } 165 | 166 | function pushMessageToSingleBatch() 167 | { 168 | putenv("gexin_pushSingleBatch_needAsync=false"); 169 | 170 | $igt = new IGeTui(HOST, APPKEY, MASTERSECRET); 171 | $batch = new IGtBatch(APPKEY, $igt); 172 | $batch->setApiUrl(HOST); 173 | //$igt->connect(); 174 | //消息模版: 175 | // 1.TransmissionTemplate:透传功能模板 176 | // 2.LinkTemplate:通知打开链接功能模板 177 | // 3.NotificationTemplate:通知透传功能模板 178 | // 4.NotyPopLoadTemplate:通知弹框下载功能模板 179 | 180 | //$template = IGtNotyPopLoadTemplateDemo(); 181 | $templateLink = IGtLinkTemplateDemo(); 182 | $templateNoti = IGtNotificationTemplateDemo(); 183 | //$template = IGtTransmissionTemplateDemo(); 184 | 185 | //个推信息体 186 | $messageLink = new IGtSingleMessage(); 187 | $messageLink->set_isOffline(true);//是否离线 188 | $messageLink->set_offlineExpireTime(12 * 1000 * 3600);//离线时间 189 | $messageLink->set_data($templateLink);//设置推送消息类型 190 | //$messageLink->set_PushNetWorkType(1);//设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送 191 | 192 | $targetLink = new IGtTarget(); 193 | $targetLink->set_appId(APPID); 194 | $targetLink->set_clientId(CID1); 195 | $batch->add($messageLink, $targetLink); 196 | 197 | //个推信息体 198 | $messageNoti = new IGtSingleMessage(); 199 | $messageNoti->set_isOffline(true);//是否离线 200 | $messageNoti->set_offlineExpireTime(12 * 1000 * 3600);//离线时间 201 | $messageNoti->set_data($templateNoti);//设置推送消息类型 202 | //$messageNoti->set_PushNetWorkType(1);//设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送 203 | 204 | $targetNoti = new IGtTarget(); 205 | $targetNoti->set_appId(APPID); 206 | $targetNoti->set_clientId(CID2); 207 | $batch->add($messageNoti, $targetNoti); 208 | try { 209 | 210 | $rep = $batch->submit(); 211 | var_dump($rep); 212 | echo("

"); 213 | }catch(Exception $e){ 214 | $rep=$batch->retry(); 215 | var_dump($rep); 216 | echo ("

"); 217 | } 218 | } 219 | 220 | //多推接口案例 221 | function pushMessageToList() 222 | { 223 | putenv("gexin_pushList_needDetails=true"); 224 | putenv("gexin_pushList_needAsync=true"); 225 | 226 | $igt = new IGeTui(HOST, APPKEY, MASTERSECRET); 227 | //消息模版: 228 | // 1.TransmissionTemplate:透传功能模板 229 | // 2.LinkTemplate:通知打开链接功能模板 230 | // 3.NotificationTemplate:通知透传功能模板 231 | // 4.NotyPopLoadTemplate:通知弹框下载功能模板 232 | 233 | 234 | //$template = IGtNotyPopLoadTemplateDemo(); 235 | //$template = IGtLinkTemplateDemo(); 236 | //$template = IGtNotificationTemplateDemo(); 237 | $template = IGtTransmissionTemplateDemo(); 238 | //个推信息体 239 | $message = new IGtListMessage(); 240 | $message->set_isOffline(true);//是否离线 241 | $message->set_offlineExpireTime(3600 * 12 * 1000);//离线时间 242 | $message->set_data($template);//设置推送消息类型 243 | // $message->set_PushNetWorkType(1); //设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送 244 | // $contentId = $igt->getContentId($message); 245 | $contentId = $igt->getContentId($message,"toList任务别名功能"); //根据TaskId设置组名,支持下划线,中文,英文,数字 246 | 247 | //接收方1 248 | $target1 = new IGtTarget(); 249 | $target1->set_appId(APPID); 250 | $target1->set_clientId(CID); 251 | // $target1->set_alias(Alias); 252 | 253 | $targetList[] = $target1; 254 | 255 | $rep = $igt->pushMessageToList($contentId, $targetList); 256 | 257 | var_dump($rep); 258 | 259 | echo ("

"); 260 | 261 | } 262 | 263 | //群推接口案例 264 | function pushMessageToApp(){ 265 | $igt = new IGeTui(HOST,APPKEY,MASTERSECRET); 266 | $template = IGtTransmissionTemplateDemo(); 267 | //$template = IGtLinkTemplateDemo(); 268 | //个推信息体 269 | //基于应用消息体 270 | $message = new IGtAppMessage(); 271 | $message->set_isOffline(true); 272 | $message->set_offlineExpireTime(10 * 60 * 1000);//离线时间单位为毫秒,例,两个小时离线为3600*1000*2 273 | $message->set_data($template); 274 | 275 | $appIdList=array(APPID); 276 | $phoneTypeList=array('ANDROID'); 277 | $provinceList=array('浙江'); 278 | $tagList=array('haha'); 279 | //用户属性 280 | //$age = array("0000", "0010"); 281 | 282 | 283 | //$cdt = new AppConditions(); 284 | // $cdt->addCondition(AppConditions::PHONE_TYPE, $phoneTypeList); 285 | // $cdt->addCondition(AppConditions::REGION, $provinceList); 286 | //$cdt->addCondition(AppConditions::TAG, $tagList); 287 | //$cdt->addCondition("age", $age); 288 | 289 | $message->set_appIdList($appIdList); 290 | //$message->set_conditions($cdt->getCondition()); 291 | 292 | $rep = $igt->pushMessageToApp($message,"任务组名"); 293 | 294 | var_dump($rep); 295 | echo ("

"); 296 | } 297 | 298 | //所有推送接口均支持四个消息模板,依次为通知弹框下载模板,通知链接模板,通知透传模板,透传模板 299 | //注:IOS离线推送需通过APN进行转发,需填写pushInfo字段,目前仅不支持通知弹框下载功能 300 | 301 | function IGtNotyPopLoadTemplateDemo(){ 302 | $template = new IGtNotyPopLoadTemplate(); 303 | 304 | $template ->set_appId(APPID);//应用appid 305 | $template ->set_appkey(APPKEY);//应用appkey 306 | //通知栏 307 | $template ->set_notyTitle("个推");//通知栏标题 308 | $template ->set_notyContent("个推最新版点击下载");//通知栏内容 309 | $template ->set_notyIcon("");//通知栏logo 310 | $template ->set_isBelled(true);//是否响铃 311 | $template ->set_isVibrationed(true);//是否震动 312 | $template ->set_isCleared(true);//通知栏是否可清除 313 | //弹框 314 | $template ->set_popTitle("弹框标题");//弹框标题 315 | $template ->set_popContent("弹框内容");//弹框内容 316 | $template ->set_popImage("");//弹框图片 317 | $template ->set_popButton1("下载");//左键 318 | $template ->set_popButton2("取消");//右键 319 | //下载 320 | $template ->set_loadIcon("");//弹框图片 321 | $template ->set_loadTitle("地震速报下载"); 322 | $template ->set_loadUrl("http://dizhensubao.igexin.com/dl/com.ceic.apk"); 323 | $template ->set_isAutoInstall(false); 324 | $template ->set_isActived(true); 325 | //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息 326 | 327 | return $template; 328 | } 329 | 330 | function IGtLinkTemplateDemo(){ 331 | $template = new IGtLinkTemplate(); 332 | $template ->set_appId(APPID);//应用appid 333 | $template ->set_appkey(APPKEY);//应用appkey 334 | $template ->set_title("请输入通知标题");//通知栏标题 335 | $template ->set_text("请输入通知内容");//通知栏内容 336 | $template ->set_logo("");//通知栏logo 337 | $template ->set_isRing(true);//是否响铃 338 | $template ->set_isVibrate(true);//是否震动 339 | $template ->set_isClearable(true);//通知栏是否可清除 340 | $template ->set_url("http://www.igetui.com/");//打开连接地址 341 | //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息 342 | return $template; 343 | } 344 | 345 | function IGtNotificationTemplateDemo(){ 346 | $template = new IGtNotificationTemplate(); 347 | $template->set_appId(APPID);//应用appid 348 | $template->set_appkey(APPKEY);//应用appkey 349 | $template->set_transmissionType(1);//透传消息类型 350 | $template->set_transmissionContent("测试离线");//透传内容 351 | $template->set_title("个推");//通知栏标题 352 | $template->set_text("个推最新版点击下载");//通知栏内容 353 | $template->set_logo("http://wwww.igetui.com/logo.png");//通知栏logo 354 | $template->set_isRing(true);//是否响铃 355 | $template->set_isVibrate(true);//是否震动 356 | $template->set_isClearable(true);//通知栏是否可清除 357 | //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息 358 | return $template; 359 | } 360 | 361 | function IGtTransmissionTemplateDemo(){ 362 | $template = new IGtTransmissionTemplate(); 363 | $template->set_appId(APPID);//应用appid 364 | $template->set_appkey(APPKEY);//应用appkey 365 | $template->set_transmissionType(1);//透传消息类型 366 | $template->set_transmissionContent("测试离线ddd");//透传内容 367 | //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息 368 | //APN简单推送 369 | // $template = new IGtAPNTemplate(); 370 | // $apn = new IGtAPNPayload(); 371 | // $alertmsg=new SimpleAlertMsg(); 372 | // $alertmsg->alertMsg=""; 373 | // $apn->alertMsg=$alertmsg; 374 | //// $apn->badge=2; 375 | //// $apn->sound=""; 376 | // $apn->add_customMsg("payload","payload"); 377 | // $apn->contentAvailable=1; 378 | // $apn->category="ACTIONABLE"; 379 | // $template->set_apnInfo($apn); 380 | // $message = new IGtSingleMessage(); 381 | 382 | //APN高级推送 383 | $apn = new IGtAPNPayload(); 384 | $alertmsg=new DictionaryAlertMsg(); 385 | $alertmsg->body="body"; 386 | $alertmsg->actionLocKey="ActionLockey"; 387 | $alertmsg->locKey="LocKey"; 388 | $alertmsg->locArgs=array("locargs"); 389 | $alertmsg->launchImage="launchimage"; 390 | // IOS8.2 支持 391 | $alertmsg->title="Title"; 392 | $alertmsg->titleLocKey="TitleLocKey"; 393 | $alertmsg->titleLocArgs=array("TitleLocArg"); 394 | 395 | $apn->alertMsg=$alertmsg; 396 | $apn->badge=7; 397 | $apn->sound=""; 398 | $apn->add_customMsg("payload","payload"); 399 | $apn->contentAvailable=1; 400 | $apn->category="ACTIONABLE"; 401 | $template->set_apnInfo($apn); 402 | 403 | //PushApn老方式传参 404 | // $template = new IGtAPNTemplate(); 405 | // $template->set_pushInfo("", 10, "", "com.gexin.ios.silence", "", "", "", ""); 406 | 407 | return $template; 408 | } 409 | 410 | 411 | 412 | ?> 413 | 414 | -------------------------------------------------------------------------------- /src/GeTuiService.php: -------------------------------------------------------------------------------- 1 | config = $config; 38 | 39 | $appEnv = $this->config["app_env"]; 40 | $client = $this->config["default_client"]; 41 | $config = $this->config[$appEnv][$client]; 42 | $this->obj = new \IGeTui($config['gt_domainurl'], $config['gt_appkey'], $config['gt_mastersecret']); 43 | $this->gt_appid = $config['gt_appid']; 44 | $this->gt_appkey = $config['gt_appkey']; 45 | $this->gt_appsecret = $config['gt_appsecret']; 46 | $this->gt_mastersecret = $config['gt_mastersecret']; 47 | } 48 | 49 | 50 | 51 | public function toClient($client = null) 52 | { 53 | $appEnv = $this->config["app_env"]; 54 | if (empty($client)) { 55 | $client = $this->config["default_client"]; 56 | } 57 | $config = $this->config[$appEnv][$client]; 58 | $this->obj = new \IGeTui($config['gt_domainurl'], $config['gt_appkey'], $config['gt_mastersecret']); 59 | $this->gt_appid = $config['gt_appid']; 60 | $this->gt_appkey = $config['gt_appkey']; 61 | $this->gt_appsecret = $config['gt_appsecret']; 62 | $this->gt_mastersecret = $config['gt_mastersecret']; 63 | return $this; 64 | } 65 | 66 | 67 | 68 | 69 | public function getPushResult($taskId) 70 | { 71 | $params = array(); 72 | $url = 'http://sdk.open.api.igexin.com/apiex.htm'; 73 | $params["action"] = "getPushMsgResult"; 74 | $params["appkey"] = $this->gt_appkey; 75 | $params["taskId"] = $taskId; 76 | $sign = $this->createSign($params, $this->gt_mastersecret); 77 | $params["sign"] = $sign; 78 | $data = json_encode($params); 79 | $result = $this->httpPost($url, $data); 80 | return $result; 81 | } 82 | 83 | public function createSign($params, $masterSecret) 84 | { 85 | $sign = $masterSecret; 86 | foreach ($params as $key => $val) { 87 | if (isset($key) && isset($val)) { 88 | if (is_string($val) || is_numeric($val)) { // 针对非 array object 对象进行sign 89 | $sign .= $key . ($val); //urldecode 90 | } 91 | } 92 | } 93 | return md5($sign); 94 | } 95 | 96 | public function httpPost($url, $data) 97 | { 98 | $curl = curl_init($url); 99 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 100 | curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1); 101 | curl_setopt($curl, CURLOPT_USERAGENT, 'GeTui PHP/1.0'); 102 | curl_setopt($curl, CURLOPT_POST, 1); 103 | curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60); 104 | curl_setopt($curl, CURLOPT_TIMEOUT, 60); 105 | curl_setopt($curl, CURLOPT_POSTFIELDS, $data); 106 | $result = curl_exec($curl); 107 | curl_close($curl); 108 | return $result; 109 | } 110 | 111 | 112 | /** 113 | * 推送单个或多个用户 114 | * @param array|string $deviceId 115 | * @param array $data 116 | * @param string $function 数据转换编码函数 117 | * 118 | * @return Message 119 | * @throws \Exception 120 | */ 121 | public function push($deviceId, array $data, $isNotice = true, $function = 'json_encode') 122 | { 123 | if (empty($deviceId)) { 124 | throw new \Exception('device_id not empty'); 125 | } 126 | 127 | if (!isset($data['content']) || !isset($data['title'])) { 128 | throw new \Exception('content and title not empty'); 129 | } 130 | $shortUrl = isset($data['url']) ? $data['url'] : ''; 131 | $message = new Message(); 132 | $message->setContent($data['content']); 133 | $content = $message->getContent(); 134 | 135 | $message->setTitle($data['title']); 136 | $title = $message->getTitle(); 137 | $transContent = $function($data); 138 | 139 | if (is_array($deviceId)) { 140 | $result = $this->pushMessageToList($deviceId, $transContent, $content, $title,$isNotice, $shortUrl); 141 | 142 | } else { 143 | $result = $this->pushMessageToSingle($deviceId, $transContent, $content, $title, $isNotice, $shortUrl); 144 | 145 | } 146 | return $result; 147 | 148 | 149 | //$2y$10$a6RR/UxbEYbmqfZi6zTiguPLV7cI.WtV7c/0.9nXeaSmf549VuDWe 150 | 151 | //$2y$10$a6RR/UxbEYbmqfZi6zTiguPLV7cI.WtV7c/0.9nXeaSmf549VuDWe 152 | 153 | 154 | //$2y$10$P7xOUnjy.AAzBY7QMxJqW.vDAai8dRmxSR3tmzlQ5HjcwVNRJNsAW 123123 155 | } 156 | 157 | 158 | /** 159 | * 发送给这个APP所有用户 160 | * 161 | * @param array $data 162 | * @param string $function 163 | * 164 | * @return Message 165 | * @throws \Exception 166 | */ 167 | public function pushToApp(array $data,$isNotice=true, $function = 'json_encode') 168 | { 169 | 170 | if (!isset($data['content']) || !isset($data['title'])) { 171 | throw new \Exception('content and title not empty'); 172 | } 173 | 174 | $message = new Message(); 175 | $message->setContent($data['content']); 176 | $content = $message->getContent(); 177 | $message->setTitle($data['title']); 178 | $title = $message->getTitle(); 179 | 180 | $transContent = $function($data); 181 | $result = $this->pushMessageToApp($transContent, $content, $title ,$isNotice); 182 | return $result; 183 | } 184 | 185 | 186 | 187 | 188 | // 189 | //服务端推送接口,支持三个接口推送 190 | //1.PushMessageToSingle接口:支持对单个用户进行推送 191 | //2.PushMessageToList接口:支持对多个用户进行推送,建议为50个用户 192 | //3.pushMessageToApp接口:对单个应用下的所有用户进行推送,可根据省份,标签,机型过滤推送 193 | // 194 | 195 | //单推接口案例 196 | function pushMessageToSingle($clientId, $transContent, $content, $title, $isNotice = true, $shortUrl = '') 197 | { 198 | //消息模版: 199 | $template = $this->getTemplate($content, $title, $transContent,$isNotice, $shortUrl); 200 | //个推信息体 201 | $message = new \IGtSingleMessage(); 202 | $message->set_isOffline(true);//是否离线 203 | 204 | if (!$isNotice) { 205 | $message->set_offlineExpireTime(100 * 1000);//离线时间 206 | } else { 207 | $message->set_offlineExpireTime(3600 * 12 * 1000);//离线时间 208 | } 209 | $message->set_data($template);//设置推送消息类型 210 | // $message->set_PushNetWorkType(0);//设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送 211 | //接收方 212 | $target = new \IGtTarget(); 213 | $target->set_appId($this->gt_appid); 214 | $target->set_clientId($clientId); 215 | // $target->set_alias(Alias); 216 | 217 | try { 218 | $rep = $this->obj->pushMessageToSingle($message, $target); 219 | return $rep; 220 | } catch (\RequestException $e) { 221 | $requstId = $e->getRequestId(); 222 | $rep = $this->obj->pushMessageToSingle($message, $target, $requstId); 223 | return $rep; 224 | } 225 | 226 | } 227 | 228 | //多推接口案例 229 | function pushMessageToList($clientIds,$transContent, $content, $title, $isNotice = true, $shortUrl = '') 230 | { 231 | putenv("gexin_pushList_needDetails=true"); 232 | putenv("gexin_pushList_needAsync=true"); 233 | //消息模版: 234 | $template = $this->getTemplate($content, $title, $transContent,$isNotice, $shortUrl); 235 | //个推信息体 236 | $message = new \IGtListMessage(); 237 | $message->set_isOffline(true);//是否离线 238 | if (!$isNotice) { 239 | $message->set_offlineExpireTime(100 * 1000);//离线时间 240 | } else { 241 | $message->set_offlineExpireTime(3600 * 12 * 1000);//离线时间 242 | } 243 | $message->set_data($template);//设置推送消息类型 244 | // $message->set_PushNetWorkType(1); //设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送 245 | // $contentId = $igt->getContentId($message); 246 | $contentId = $this->obj->getContentId($message, "toList任务别名功能"); //根据TaskId设置组名,支持下划线,中文,英文,数字 247 | 248 | //接收方1 249 | $targetList = []; 250 | foreach ($clientIds as $key => $clientId) { 251 | $target = new \IGtTarget(); 252 | $target->set_appId($this->gt_appid); 253 | $target->set_clientId($clientId); 254 | $targetList[] = $target; 255 | } 256 | 257 | // $target1->set_alias(Alias); 258 | $rep = $this->obj->pushMessageToList($contentId, $targetList); 259 | return $rep; 260 | 261 | } 262 | 263 | 264 | //群推接口案例 265 | function pushMessageToApp($transContent, $content, $title, $isNotice = true, $shortUrl = '') 266 | { 267 | $template = $this->getTemplate($content, $title, $transContent, $isNotice, $shortUrl); 268 | //个推信息体 269 | //基于应用消息体 270 | $message = new \IGtAppMessage(); 271 | $message->set_isOffline(true); 272 | 273 | if (!$isNotice) { 274 | $message->set_offlineExpireTime(100 * 1000);//离线时间 275 | } else { 276 | $message->set_offlineExpireTime(3600 * 12 * 1000);//离线时间 277 | } 278 | $message->set_data($template); 279 | 280 | $appIdList = array($this->gt_appid); 281 | $phoneTypeList = array('ANDROID'); 282 | $provinceList = array('浙江'); 283 | $tagList = array('haha'); 284 | //用户属性 285 | //$age = array("0000", "0010"); 286 | 287 | //$cdt = new AppConditions(); 288 | // $cdt->addCondition(AppConditions::PHONE_TYPE, $phoneTypeList); 289 | // $cdt->addCondition(AppConditions::REGION, $provinceList); 290 | //$cdt->addCondition(AppConditions::TAG, $tagList); 291 | //$cdt->addCondition("age", $age); 292 | 293 | $message->set_appIdList($appIdList); 294 | //$message->set_conditions($cdt->getCondition()); 295 | 296 | $rep = $this->obj->pushMessageToApp($message, "任务组名"); 297 | 298 | return $rep; 299 | 300 | } 301 | 302 | 303 | protected function getTemplate($content, $title, $transContent, $isNotice = true, $shortUrl = '') 304 | { 305 | // switch ($type) { 306 | // case self::ALL: 307 | // return $this->IGtNotificationTemplateDemo($content, $title, $transContent); 308 | // case self::NOTICE: 309 | // return $this->IGtNotyPopLoadTemplateDemo($content, $title, $transContent); 310 | // case self::PENETRATE: 311 | // return $this->IGtTransmissionTemplateDemo($content, $title, $transContent); 312 | // case self::H5: 313 | // return $this->IGtLinkTemplateDemo($content, $title, $shortUrl); 314 | // } 315 | 316 | if ($isNotice) { 317 | return $this->IGtNotificationTemplateDemo($content, $title, $transContent); 318 | } 319 | return $this->IGtTransmissionTemplateDemo($content, $title, $transContent); 320 | } 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | //所有推送接口均支持四个消息模板,依次为通知弹框下载模板,通知链接模板,通知透传模板,透传模板 329 | //注:IOS离线推送需通过APN进行转发,需填写pushInfo字段,目前仅不支持通知弹框下载功能 330 | 331 | 332 | //推送通知 333 | function IGtNotyPopLoadTemplateDemo($content, $title, $transContent) 334 | { 335 | $template = new \IGtNotyPopLoadTemplate(); 336 | 337 | $template->set_appId($this->gt_appid);//应用appid 338 | $template->set_appkey($this->gt_appkey);//应用appkey 339 | //通知栏 340 | $template->set_notyTitle($title);//通知栏标题 341 | $template->set_notyContent($content);//通知栏内容 342 | $template->set_notyIcon("");//通知栏logo 343 | $template->set_isBelled(true);//是否响铃 344 | $template->set_isVibrationed(true);//是否震动 345 | $template->set_isCleared(true);//通知栏是否可清除 346 | //弹框 347 | $template->set_popTitle($title);//弹框标题 348 | $template->set_popContent($transContent);//弹框内容 349 | $template->set_popImage("");//弹框图片 350 | $template->set_popButton1("下载");//左键 351 | $template->set_popButton2("取消");//右键 352 | // 下载 353 | $template->set_loadIcon("");//弹框图片 354 | $template->set_loadTitle("地震速报下载"); 355 | $template->set_loadUrl("http://dizhensubao.igexin.com/dl/com.ceic.apk"); 356 | $template->set_isAutoInstall(false); 357 | $template->set_isActived(true); 358 | //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息 359 | 360 | return $template; 361 | } 362 | 363 | //推送通知链接模板 364 | function IGtLinkTemplateDemo($content, $title, $url) 365 | { 366 | $template = new \IGtLinkTemplate(); 367 | $template->set_appId($this->gt_appid);//应用appid 368 | $template->set_appkey($this->gt_appkey);//应用appkey 369 | $template->set_title($title);//通知栏标题 370 | $template->set_text($content);//通知栏内容 371 | $template->set_logo("");//通知栏logo 372 | $template->set_isRing(true);//是否响铃 373 | $template->set_isVibrate(true);//是否震动 374 | $template->set_isClearable(true);//通知栏是否可清除 375 | $template->set_url($url);//打开连接地址 376 | //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息 377 | return $template; 378 | } 379 | 380 | 381 | //透传模板 382 | function IGtTransmissionTemplateDemo($content, $title, $transContent) 383 | { 384 | $template = new \IGtTransmissionTemplate(); 385 | $template->set_appId($this->gt_appid);//应用appid 386 | $template->set_appkey($this->gt_appkey);//应用appkey 387 | $template->set_transmissionType(2);//透传消息类型,自动打开应用 388 | $template->set_transmissionContent($transContent);//透传内容 389 | //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息 390 | 391 | //APN高级推送 392 | $apn = new \IGtAPNPayload(); 393 | $alertmsg = new \DictionaryAlertMsg(); 394 | $alertmsg->body = $content; 395 | $alertmsg->actionLocKey = "ActionLockey"; 396 | $alertmsg->locKey = "LocKey"; 397 | $alertmsg->locArgs = array("locargs"); 398 | $alertmsg->launchImage = "launchimage"; 399 | // IOS8.2 支持 400 | $alertmsg->title = $title; 401 | $alertmsg->titleLocKey = "TitleLocKey"; 402 | $alertmsg->titleLocArgs = array("TitleLocArg"); 403 | 404 | $apn->alertMsg = $alertmsg; 405 | $apn->badge = 1; 406 | $apn->sound = ""; 407 | $apn->add_customMsg("payload", $transContent); 408 | $apn->contentAvailable = 1; 409 | $apn->category = "ACTIONABLE"; 410 | $template->set_apnInfo($apn); 411 | return $template; 412 | } 413 | 414 | 415 | //通知+透传模板 416 | function IGtNotificationTemplateDemo($content, $title, $transContent) 417 | { 418 | $template = new \IGtNotificationTemplate(); 419 | $template->set_appId($this->gt_appid);//应用appid 420 | $template->set_appkey($this->gt_appkey);//应用appkey 421 | $template->set_transmissionType(1);//透传消息类型 422 | $template->set_transmissionContent($transContent);//透传内容 423 | $template->set_title($title);//通知栏标题 424 | $template->set_text($content);//通知栏内容 425 | $template->set_logo("");//通知栏logo 426 | $template->set_isRing(true);//是否响铃 427 | $template->set_isVibrate(true);//是否震动 428 | $template->set_isClearable(true);//通知栏是否可清除 429 | //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息 430 | return $template; 431 | } 432 | 433 | 434 | } 435 | -------------------------------------------------------------------------------- /src/getui/IGt.Push.php: -------------------------------------------------------------------------------- 1 | appkey = $appkey; 40 | $this->masterSecret = $masterSecret; 41 | 42 | $domainUrl = trim($domainUrl); 43 | if ($ssl == NULL && $domainUrl != NULL && strpos(strtolower($domainUrl), "https:") === 0) 44 | { 45 | $ssl = true; 46 | } 47 | $this->useSSL = ($ssl == NULL ? false : $ssl); 48 | 49 | if ($domainUrl == NULL || strlen($domainUrl) == 0) 50 | { 51 | $this->domainUrlList = GTConfig::getDefaultDomainUrl($this->useSSL); 52 | } 53 | else 54 | { 55 | $this->domainUrlList = array($domainUrl); 56 | } 57 | $this->initOSDomain(null); 58 | } 59 | 60 | private function initOSDomain($hosts) 61 | { 62 | if($hosts == null || count($hosts) == 0) 63 | { 64 | $hosts = isset(IGeTui::$appkeyUrlList[$this->appkey])?IGeTui::$appkeyUrlList[$this->appkey]:null; 65 | if($hosts == null || count($hosts) == 0) 66 | { 67 | $hosts = $this->getOSPushDomainUrlList($this->domainUrlList,$this->appkey); 68 | IGeTui::$appkeyUrlList[$this->appkey] = $hosts; 69 | } 70 | } 71 | else 72 | { 73 | IGeTui::$appkeyUrlList[$this->appkey] = $hosts; 74 | } 75 | $this->host = ApiUrlRespectUtils::getFastest($this->appkey, $hosts); 76 | return $this->host; 77 | } 78 | 79 | public function getOSPushDomainUrlList($domainUrlList,$appkey) 80 | { 81 | $urlList = null; 82 | $postData = array(); 83 | $postData['action']='getOSPushDomailUrlListAction'; 84 | $postData['appkey'] = $appkey; 85 | $ex = null; 86 | foreach($domainUrlList as $durl) 87 | { 88 | try 89 | { 90 | $response = $this->httpPostJSON($durl,$postData); 91 | $urlList = isset($response["osList"])?$response["osList"]:null; 92 | if($urlList != null && count($urlList) > 0) 93 | { 94 | break; 95 | } 96 | } 97 | catch (Exception $e) 98 | { 99 | $ex = $e; 100 | } 101 | } 102 | if($urlList == null || count($urlList) <= 0) 103 | { 104 | $h = implode(',', $domainUrlList); 105 | throw new Exception("Can not get hosts from ".$h."|error:".$ex); 106 | } 107 | return $urlList; 108 | } 109 | 110 | function httpPostJSON($url,$data,$gzip=false) 111 | { 112 | if($url == null){ 113 | $url = $this->host; 114 | } 115 | $rep = HttpManager::httpPostJson($url, $data, $gzip); 116 | if($rep != null) 117 | { 118 | if ( 'sign_error' == $rep['result']) { 119 | try 120 | { 121 | if ($this->connect()) 122 | { 123 | $rep = HttpManager::httpPostJson($url, $data, $gzip); 124 | } 125 | } 126 | catch (Exception $e) 127 | { 128 | throw new Exception("连接异常".$e); 129 | } 130 | } 131 | else if('domain_error' == $rep['result']) 132 | { 133 | $this->initOSDomain(isset($rep["osList"])?$rep["osList"]:null); 134 | $rep = HttpManager::httpPostJson($url, $data, $gzip); 135 | } 136 | } 137 | return $rep; 138 | } 139 | 140 | public function connect() 141 | { 142 | $timeStamp = $this->micro_time(); 143 | // 计算sign值 144 | $sign = md5($this->appkey . $timeStamp . $this->masterSecret); 145 | // 146 | $params = array(); 147 | 148 | $params["action"] = "connect"; 149 | $params["appkey"] = $this->appkey; 150 | $params["timeStamp"] = $timeStamp; 151 | $params["sign"] = $sign; 152 | $rep = HttpManager::httpPostJson($this->host,$params,false); 153 | if ('success' == $rep['result']) { 154 | return true; 155 | } 156 | throw new Exception("appKey Or masterSecret is Auth Failed"); 157 | } 158 | 159 | public function close() 160 | { 161 | $params = array(); 162 | $params["action"] = "close"; 163 | $params["appkey"] = $this->appKey; 164 | HttpManager::httpPostJson($this->host,$params,false); 165 | } 166 | 167 | /** 168 | * 指定用户推送消息 169 | * @param IGtMessage message 170 | * @param IGtTarget target 171 | * @return Array {result:successed_offline,taskId:xxx} || {result:successed_online,taskId:xxx} || {result:error} 172 | ***/ 173 | public function pushMessageToSingle($message, $target, $requestId = null) 174 | { 175 | if($requestId == null || trim($requestId) == "") 176 | { 177 | $requestId = uniqid(); 178 | } 179 | $params = $this->getSingleMessagePostData($message, $target, $requestId); 180 | return $this->httpPostJSON($this->host,$params); 181 | } 182 | 183 | 184 | function getSingleMessagePostData($message, $target, $requestId = null){ 185 | $params = array(); 186 | $params["action"] = "pushMessageToSingleAction"; 187 | $params["appkey"] = $this -> appkey; 188 | if($requestId != null) 189 | { 190 | $params["requestId"] = $requestId; 191 | } 192 | 193 | $params["clientData"] = base64_encode($message->get_data()->get_transparent()); 194 | $params["transmissionContent"] = $message->get_data()->get_transmissionContent(); 195 | $params["isOffline"] = $message->get_isOffline(); 196 | $params["offlineExpireTime"] = $message->get_offlineExpireTime(); 197 | // 增加pushNetWorkType参数(0:不限;1:wifi;2:4G/3G/2G) 198 | $params["pushNetWorkType"] = $message->get_pushNetWorkType(); 199 | 200 | // 201 | $params["appId"] = $target->get_appId(); 202 | $params["clientId"] = $target->get_clientId(); 203 | $params["alias"] = $target->get_alias(); 204 | // 默认都为消息 205 | $params["type"] = 2; 206 | $params["pushType"] = $message->get_data()->get_pushType(); 207 | return $params; 208 | } 209 | 210 | public function getContentId($message,$taskGroupName = null) 211 | { 212 | return $this->getListAppContentId($message,$taskGroupName); 213 | } 214 | 215 | /** 216 | * 取消消息 217 | * @param String contentId 218 | * @return boolean 219 | ***/ 220 | public function cancelContentId($contentId) 221 | { 222 | $params = array(); 223 | $params["action"] = "cancleContentIdAction"; 224 | $params["appkey"] = $this->appKey; 225 | $params["contentId"] = $contentId; 226 | $rep = $this->httpPostJSON($this->host,$params); 227 | return $rep['result'] == 'ok' ? true : false; 228 | } 229 | 230 | /** 231 | * 批量推送信息 232 | * @param String contentId 233 | * @param Array targetList 234 | * @return Array {result:successed_offline,taskId:xxx} || {result:successed_online,taskId:xxx} || {result:error} 235 | ***/ 236 | public function pushMessageToList($contentId, $targetList) 237 | { 238 | $params = array(); 239 | $params["action"] = "pushMessageToListAction"; 240 | $params["appkey"] = $this-> appkey; 241 | $params["contentId"] = $contentId; 242 | $needDetails = GTConfig::isPushListNeedDetails(); 243 | $params["needDetails"] = $needDetails; 244 | $async = GTConfig::isPushListAsync(); 245 | $params["async"] = $async; 246 | if($async && (!$needDetails)) 247 | { 248 | $limit = GTConfig::getAsyncListLimit(); 249 | } 250 | else 251 | { 252 | $limit = GTConfig::getSyncListLimit(); 253 | } 254 | if(count($targetList) > $limit) 255 | { 256 | throw new Exception("target size:".count($targetList)." beyond the limit:".$limit); 257 | } 258 | $clientIdList = array(); 259 | $aliasList= array(); 260 | $appId = null; 261 | foreach($targetList as $target) 262 | { 263 | $targetCid = $target->get_clientId(); 264 | $targetAlias = $target->get_alias(); 265 | if($targetCid != null) 266 | { 267 | array_push($clientIdList,$targetCid); 268 | }elseif($targetAlias != null) 269 | { 270 | array_push($aliasList,$targetAlias); 271 | } 272 | if($appId == null) 273 | { 274 | $appId = $target->get_appId(); 275 | } 276 | 277 | } 278 | $params["appId"] = $appId; 279 | $params["clientIdList"] = $clientIdList; 280 | $params["aliasList"] = $aliasList; 281 | $params["type"] = 2; 282 | return $this->httpPostJSON($this->host,$params,true); 283 | } 284 | 285 | public function stop($contentId) 286 | { 287 | $params = array(); 288 | $params["action"] = "stopTaskAction"; 289 | $params["appkey"] = $this->appkey; 290 | $params["contentId"] = $contentId; 291 | $rep = $this->httpPostJSON($this->host, $params); 292 | if ("ok" == $rep["result"]) { 293 | return true; 294 | } 295 | return false; 296 | } 297 | 298 | public function getClientIdStatus($appId, $clientId) 299 | { 300 | $params = array(); 301 | $params["action"] = "getClientIdStatusAction"; 302 | $params["appkey"] = $this->appkey; 303 | $params["appId"] = $appId; 304 | $params["clientId"] = $clientId; 305 | return $this->httpPostJSON($this->host, $params); 306 | } 307 | 308 | public function setClientTag($appId, $clientId, $tags) 309 | { 310 | $params = array(); 311 | $params["action"] = "setTagAction"; 312 | $params["appkey"] = $this->appkey; 313 | $params["appId"] = $appId; 314 | $params["clientId"] = $clientId; 315 | $params["tagList"] = $tags; 316 | return $this->httpPostJSON($this->host, $params); 317 | } 318 | 319 | public function pushMessageToApp($message, $taskGroupName = null) 320 | { 321 | $contentId = $this->getListAppContentId($message, $taskGroupName); 322 | $params = array(); 323 | $params["action"] = "pushMessageToAppAction"; 324 | $params["appkey"] = $this->appkey; 325 | $params["contentId"] = $contentId; 326 | $params["type"] = 2; 327 | return $this->httpPostJSON($this->host,$params); 328 | } 329 | 330 | private function getListAppContentId($message, $taskGroupName = null) 331 | { 332 | $params = array(); 333 | if (!is_null($taskGroupName) && trim($taskGroupName) != ""){ 334 | if(strlen($taskGroupName) > 40){ 335 | throw new Exception("TaskGroupName is OverLimit 40"); 336 | } 337 | $params["taskGroupName"] = $taskGroupName; 338 | } 339 | $params["action"] = "getContentIdAction"; 340 | $params["appkey"] = $this->appkey; 341 | $params["clientData"] = base64_encode($message->get_data()->get_transparent()); 342 | $params["transmissionContent"] = $message->get_data()->get_transmissionContent(); 343 | $params["isOffline"] = $message->get_isOffline(); 344 | $params["offlineExpireTime"] = $message->get_offlineExpireTime(); 345 | // 增加pushNetWorkType参数(0:不限;1:wifi;2:4G/3G/2G) 346 | $params["pushNetWorkType"] = $message->get_pushNetWorkType(); 347 | $params["pushType"] = $message->get_data()->get_pushType(); 348 | $params["type"] = 2; 349 | //contentType 1是appMessage,2是listMessage 350 | if ($message instanceof IGtListMessage){ 351 | $params["contentType"] = 1; 352 | } else { 353 | $params["contentType"] = 2; 354 | $params["appIdList"] = $message->get_appIdList(); 355 | $params["speed"] = $message->get_speed(); 356 | //$params["personaTags"] 357 | $personaTags = array(); 358 | if($message->get_conditions() == null) { 359 | $params["phoneTypeList"] = $message->get_phoneTypeList(); 360 | $params["provinceList"] = $message->get_provinceList(); 361 | $params["tagList"] = $message->get_tagList(); 362 | } else { 363 | $conditions = $message->get_conditions(); 364 | $params["conditions"] = $conditions->getCondition(); 365 | } 366 | } 367 | $rep = $this->httpPostJSON($this->host,$params); 368 | if($rep['result'] == 'ok') 369 | { 370 | return $rep['contentId']; 371 | }else{ 372 | throw new Exception("host:[".$this->host."]" + "获取contentId失败:".$rep); 373 | } 374 | } 375 | 376 | public function getBatch() 377 | { 378 | return new IGtBatch($this->appkey,$this); 379 | } 380 | 381 | public function pushAPNMessageToSingle($appId, $deviceToken, $message) 382 | { 383 | $params = array(); 384 | $params['action'] = 'apnPushToSingleAction'; 385 | $params['appId'] = $appId; 386 | $params['appkey'] = $this->appkey; 387 | $params['DT'] = $deviceToken; 388 | $params['PI'] = base64_encode($message->get_data()->get_pushInfo()->SerializeToString()); 389 | return $this->httpPostJSON($this->host,$params); 390 | } 391 | 392 | /** 393 | * 根据deviceTokenList群推 394 | * @param $appId 395 | * @param $contentId 396 | * @param $deviceTokenList 397 | * @return mixed 398 | */ 399 | public function pushAPNMessageToList($appId, $contentId, $deviceTokenList) 400 | { 401 | $params = array(); 402 | $params["action"] = "apnPushToListAction"; 403 | $params["appkey"] = $this->appkey; 404 | $params["appId"] = $appId; 405 | $params["contentId"] = $contentId; 406 | $params["DTL"] = $deviceTokenList; 407 | $needDetails = GTConfig::isPushListNeedDetails(); 408 | $params["needDetails"]=$needDetails; 409 | return $this->httpPostJSON($this->host,$params); 410 | } 411 | /** 412 | * 获取apn contentId 413 | * @param $appId 414 | * @param $message 415 | * @return string 416 | */ 417 | public function getAPNContentId($appId, $message) 418 | { 419 | $params = array(); 420 | $params["action"] = "apnGetContentIdAction"; 421 | $params["appkey"] = $this->appkey; 422 | $params["appId"] = $appId; 423 | $params["PI"] = base64_encode($message->get_data()->get_pushInfo()->SerializeToString()); 424 | $rep = $this->httpPostJSON($this->host,$params); 425 | if($rep['result'] == 'ok'){ 426 | return $rep['contentId']; 427 | }else{ 428 | throw new Exception("host:[".$this->host."]" + "获取contentId失败:".$rep); 429 | } 430 | } 431 | 432 | public function bindAlias($appId, $alias, $clientId) 433 | { 434 | $params = array(); 435 | $params["action"] = "alias_bind"; 436 | $params["appkey"] = $this->appkey; 437 | $params["appid"] = $appId; 438 | $params["alias"] = $alias;; 439 | $params["cid"] = $clientId; 440 | return $this->httpPostJSON($this->host,$params); 441 | } 442 | 443 | public function bindAliasBatch($appId, $targetList) 444 | { 445 | $params = array(); 446 | $aliasList = array(); 447 | foreach($targetList as $target) { 448 | $user = array(); 449 | $user["cid"] = $target->get_clientId(); 450 | $user["alias"] = $target->get_alias(); 451 | array_push($aliasList, $user); 452 | } 453 | $params["action"] = "alias_bind_list"; 454 | $params["appkey"] = $this->appkey; 455 | $params["appid"] = $appId; 456 | $params["aliaslist"] = $aliasList; 457 | return $this->httpPostJSON($this->host,$params); 458 | } 459 | 460 | public function queryClientId($appId, $alias) 461 | { 462 | $params = array(); 463 | $params["action"] = "alias_query"; 464 | $params["appkey"] = $this->appkey; 465 | $params["appid"] = $appId; 466 | $params["alias"] = $alias;; 467 | return $this->httpPostJSON($this->host, $params); 468 | } 469 | 470 | public function queryAlias($appId, $clientId) 471 | { 472 | $params = array(); 473 | $params["action"] = "alias_query"; 474 | $params["appkey"] = $this->appkey; 475 | $params["appid"] = $appId; 476 | $params["cid"] = $clientId; 477 | return $this->httpPostJSON($this->host, $params); 478 | } 479 | 480 | public function unBindAlias($appId, $alias, $clientId=null) 481 | { 482 | $params = array(); 483 | $params["action"] = "alias_unbind"; 484 | $params["appkey"] = $this->appkey; 485 | $params["appid"] = $appId; 486 | $params["alias"] = $alias; 487 | if (!is_null($clientId) && trim($clientId) != "") 488 | { 489 | $params["cid"] = $clientId; 490 | } 491 | return $this->httpPostJSON($this->host, $params); 492 | } 493 | 494 | public function unBindAliasAll($appId, $alias) 495 | { 496 | return $this->unBindAlias($appId, $alias); 497 | } 498 | 499 | public function getPushResult( $taskId) { 500 | $params = array(); 501 | $params["action"] = "getPushMsgResult"; 502 | $params["appkey"] = $this->appkey; 503 | $params["taskId"] = $taskId; 504 | return $this->httpPostJson($this->host, $params); 505 | } 506 | 507 | public function getPushResultByTaskidList( $taskIdList) { 508 | return $this->getPushActionResultByTaskids($taskIdList, null); 509 | } 510 | 511 | public function getPushActionResultByTaskids( $taskIdList, $actionIdList) { 512 | $params = array(); 513 | $params["action"] = "getPushMsgResultByTaskidList"; 514 | $params["appkey"] = $this->appkey; 515 | $params["taskIdList"] = $taskIdList; 516 | $params["actionIdList"] = $actionIdList; 517 | return $this->httpPostJson($this->host, $params); 518 | } 519 | 520 | public function getUserTags($appId, $clientId) { 521 | $params = array(); 522 | $params["action"] = "getUserTags"; 523 | $params["appkey"] = $this->appkey; 524 | $params["appId"] = $appId; 525 | $params["clientId"] = $clientId; 526 | return $this->httpPostJson($this->host, $params); 527 | } 528 | 529 | public function getUserCountByTags($appId, $tagList) { 530 | $params = array(); 531 | $params["action"] = "getUserCountByTags"; 532 | $params["appkey"] = $this->appkey; 533 | $params["appId"] = $appId; 534 | $params["tagList"] = $tagList; 535 | $limit = GTConfig::getTagListLimit(); 536 | if(count($tagList) > $limit) { 537 | throw new Exception("tagList size:".count($tagList)." beyond the limit:".$limit); 538 | } 539 | return $this->httpPostJSON($this->host, $params); 540 | } 541 | 542 | public function getPersonaTags($appId) { 543 | $params = array(); 544 | $params["action"] = "getPersonaTags"; 545 | $params["appkey"] = $this->appkey; 546 | $params["appId"] = $appId; 547 | 548 | return $this->httpPostJSON($this->host, $params); 549 | } 550 | 551 | public function queryAppPushDataByDate($appId, $date){ 552 | if(!LangUtils::validateDate($date)){ 553 | throw new Exception("DateError|".$date); 554 | } 555 | $params = array(); 556 | $params["action"] = "queryAppPushData"; 557 | $params["appkey"] = $this->appkey; 558 | $params["appId"] = $appId; 559 | $params["date"] = $date; 560 | return $this->httpPostJson($this->host, $params); 561 | } 562 | 563 | public function queryAppUserDataByDate($appId, $date){ 564 | if(!LangUtils::validateDate($date)){ 565 | throw new Exception("DateError|".$date); 566 | } 567 | $params = array(); 568 | $params["action"] = "queryAppUserData"; 569 | $params["appkey"] = $this->appkey; 570 | $params["appId"] = $appId; 571 | $params["date"] = $date; 572 | return $this->httpPostJson($this->host, $params); 573 | } 574 | 575 | public function queryUserCount($appId, $appConditions) { 576 | $params = array(); 577 | $params["action"] = "queryUserCount"; 578 | $params["appkey"] = $this->appkey; 579 | $params["appId"] = $appId; 580 | if(!is_null($appConditions)) { 581 | $params["conditions"] = $appConditions->condition; 582 | } 583 | return $this->httpPostJson($this->host, $params); 584 | } 585 | 586 | public function pushTagMessage($message, $requestId = null) { 587 | if(!$message instanceof IGtTagMessage) { 588 | return $this->get_result("MsgTypeError"); 589 | } 590 | 591 | if($requestId == null || trim($requestId) == "") { 592 | $requestId = uniqid(); 593 | } 594 | 595 | $params = array(); 596 | $params["action"] = "pushMessageByTagAction"; 597 | $params["appkey"] = $this->appkey; 598 | $params["clientData"] = base64_encode($message->get_data()->get_transparent()); 599 | $params["transmissionContent"] = $message->get_data()->get_transmissionContent(); 600 | $params["isOffline"] = $message->get_isOffline(); 601 | $params["offlineExpireTime"] = $message->get_offlineExpireTime(); 602 | $params["pushNetWorkType"] = $message->get_pushNetWorkType(); 603 | $params["appIdList"] = $message->get_appIdList(); 604 | $params["speed"] = $message->get_speed(); 605 | $params["requestId"] = $requestId; 606 | 607 | $params["tag"] = $message->get_tag(); 608 | return $this->httpPostJSON($this->host, $params); 609 | } 610 | 611 | private function get_result($info) { 612 | $ret = array(); 613 | $ret["result"] = $info; 614 | return $ret; 615 | } 616 | 617 | private function micro_time() 618 | { 619 | list($usec, $sec) = explode(" ", microtime()); 620 | $time = ($sec . substr($usec, 2, 3)); 621 | return $time; 622 | } 623 | } 624 | -------------------------------------------------------------------------------- /src/getui/igetui/IGt.Req.last.php: -------------------------------------------------------------------------------- 1 | fields["1"] = "PBString"; 28 | $this->values["1"] = ""; 29 | $this->fields["2"] = "PBString"; 30 | $this->values["2"] = ""; 31 | $this->fields["3"] = "PBInt"; 32 | $this->values["3"] = ""; 33 | $this->fields["4"] = "PBString"; 34 | $this->values["4"] = ""; 35 | } 36 | function sign() 37 | { 38 | return $this->_get_value("1"); 39 | } 40 | function set_sign($value) 41 | { 42 | return $this->_set_value("1", $value); 43 | } 44 | function appkey() 45 | { 46 | return $this->_get_value("2"); 47 | } 48 | function set_appkey($value) 49 | { 50 | return $this->_set_value("2", $value); 51 | } 52 | function timestamp() 53 | { 54 | return $this->_get_value("3"); 55 | } 56 | function set_timestamp($value) 57 | { 58 | return $this->_set_value("3", $value); 59 | } 60 | function seqId() 61 | { 62 | return $this->_get_value("4"); 63 | } 64 | function set_seqId($value) 65 | { 66 | return $this->_set_value("4", $value); 67 | } 68 | } 69 | class GtAuthResult_GtAuthResultCode extends PBEnum 70 | { 71 | const successed = 0; 72 | const failed_noSign = 1; 73 | const failed_noAppkey = 2; 74 | const failed_noTimestamp = 3; 75 | const failed_AuthIllegal = 4; 76 | const redirect = 5; 77 | } 78 | class GtAuthResult extends PBMessage 79 | { 80 | var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; 81 | public function __construct($reader=null) 82 | { 83 | parent::__construct($reader); 84 | $this->fields["1"] = "PBInt"; 85 | $this->values["1"] = ""; 86 | $this->fields["2"] = "PBString"; 87 | $this->values["2"] = ""; 88 | $this->fields["3"] = "PBString"; 89 | $this->values["3"] = ""; 90 | $this->fields["4"] = "PBString"; 91 | $this->values["4"] = ""; 92 | } 93 | function code() 94 | { 95 | return $this->_get_value("1"); 96 | } 97 | function set_code($value) 98 | { 99 | return $this->_set_value("1", $value); 100 | } 101 | function redirectAddress() 102 | { 103 | return $this->_get_value("2"); 104 | } 105 | function set_redirectAddress($value) 106 | { 107 | return $this->_set_value("2", $value); 108 | } 109 | function seqId() 110 | { 111 | return $this->_get_value("3"); 112 | } 113 | function set_seqId($value) 114 | { 115 | return $this->_set_value("3", $value); 116 | } 117 | function info() 118 | { 119 | return $this->_get_value("4"); 120 | } 121 | function set_info($value) 122 | { 123 | return $this->_set_value("4", $value); 124 | } 125 | } 126 | class ReqServList extends PBMessage 127 | { 128 | var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; 129 | public function __construct($reader=null) 130 | { 131 | parent::__construct($reader); 132 | $this->fields["1"] = "PBString"; 133 | $this->values["1"] = ""; 134 | $this->fields["3"] = "PBInt"; 135 | $this->values["3"] = ""; 136 | } 137 | function seqId() 138 | { 139 | return $this->_get_value("1"); 140 | } 141 | function set_seqId($value) 142 | { 143 | return $this->_set_value("1", $value); 144 | } 145 | function timestamp() 146 | { 147 | return $this->_get_value("3"); 148 | } 149 | function set_timestamp($value) 150 | { 151 | return $this->_set_value("3", $value); 152 | } 153 | } 154 | class ReqServListResult_ReqServHostResultCode extends PBEnum 155 | { 156 | const successed = 0; 157 | const failed = 1; 158 | const busy = 2; 159 | } 160 | class ReqServListResult extends PBMessage 161 | { 162 | var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; 163 | public function __construct($reader=null) 164 | { 165 | parent::__construct($reader); 166 | $this->fields["1"] = "PBInt"; 167 | $this->values["1"] = ""; 168 | $this->fields["2"] = "PBString"; 169 | $this->values["2"] = array(); 170 | $this->fields["3"] = "PBString"; 171 | $this->values["3"] = ""; 172 | } 173 | function code() 174 | { 175 | return $this->_get_value("1"); 176 | } 177 | function set_code($value) 178 | { 179 | return $this->_set_value("1", $value); 180 | } 181 | function host($offset) 182 | { 183 | $v = $this->_get_arr_value("2", $offset); 184 | return $v->get_value(); 185 | } 186 | function append_host($value) 187 | { 188 | $v = $this->_add_arr_value("2"); 189 | $v->set_value($value); 190 | } 191 | function set_host($index, $value) 192 | { 193 | $v = new $this->fields["2"](); 194 | $v->set_value($value); 195 | $this->_set_arr_value("2", $index, $v); 196 | } 197 | function remove_last_host() 198 | { 199 | $this->_remove_last_arr_value("2"); 200 | } 201 | function host_size() 202 | { 203 | return $this->_get_arr_size("2"); 204 | } 205 | function seqId() 206 | { 207 | return $this->_get_value("3"); 208 | } 209 | function set_seqId($value) 210 | { 211 | return $this->_set_value("3", $value); 212 | } 213 | } 214 | class PushResult_EPushResult extends PBEnum 215 | { 216 | const successed_online = 0; 217 | const successed_offline = 1; 218 | const successed_ignore = 2; 219 | const failed = 3; 220 | const busy = 4; 221 | const success_startBatch = 5; 222 | const success_endBatch = 6; 223 | } 224 | class PushResult extends PBMessage 225 | { 226 | var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; 227 | public function __construct($reader=null) 228 | { 229 | parent::__construct($reader); 230 | $this->fields["1"] = "PushResult_EPushResult"; 231 | $this->values["1"] = ""; 232 | $this->fields["2"] = "PBString"; 233 | $this->values["2"] = ""; 234 | $this->fields["3"] = "PBString"; 235 | $this->values["3"] = ""; 236 | $this->fields["4"] = "PBString"; 237 | $this->values["4"] = ""; 238 | $this->fields["5"] = "PBString"; 239 | $this->values["5"] = ""; 240 | $this->fields["6"] = "PBString"; 241 | $this->values["6"] = ""; 242 | $this->fields["7"] = "PBString"; 243 | $this->values["7"] = ""; 244 | } 245 | function result() 246 | { 247 | return $this->_get_value("1"); 248 | } 249 | function set_result($value) 250 | { 251 | return $this->_set_value("1", $value); 252 | } 253 | function taskId() 254 | { 255 | return $this->_get_value("2"); 256 | } 257 | function set_taskId($value) 258 | { 259 | return $this->_set_value("2", $value); 260 | } 261 | function messageId() 262 | { 263 | return $this->_get_value("3"); 264 | } 265 | function set_messageId($value) 266 | { 267 | return $this->_set_value("3", $value); 268 | } 269 | function seqId() 270 | { 271 | return $this->_get_value("4"); 272 | } 273 | function set_seqId($value) 274 | { 275 | return $this->_set_value("4", $value); 276 | } 277 | function target() 278 | { 279 | return $this->_get_value("5"); 280 | } 281 | function set_target($value) 282 | { 283 | return $this->_set_value("5", $value); 284 | } 285 | function info() 286 | { 287 | return $this->_get_value("6"); 288 | } 289 | function set_info($value) 290 | { 291 | return $this->_set_value("6", $value); 292 | } 293 | function traceId() 294 | { 295 | return $this->_get_value("7"); 296 | } 297 | function set_traceId($value) 298 | { 299 | return $this->_set_value("7", $value); 300 | } 301 | } 302 | class PushListResult extends PBMessage 303 | { 304 | var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; 305 | public function __construct($reader=null) 306 | { 307 | parent::__construct($reader); 308 | $this->fields["1"] = "PushResult"; 309 | $this->values["1"] = array(); 310 | } 311 | function results($offset) 312 | { 313 | return $this->_get_arr_value("1", $offset); 314 | } 315 | function add_results() 316 | { 317 | return $this->_add_arr_value("1"); 318 | } 319 | function set_results($index, $value) 320 | { 321 | $this->_set_arr_value("1", $index, $value); 322 | } 323 | function remove_last_results() 324 | { 325 | $this->_remove_last_arr_value("1"); 326 | } 327 | function results_size() 328 | { 329 | return $this->_get_arr_size("1"); 330 | } 331 | } 332 | class Button extends PBMessage 333 | { 334 | var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; 335 | public function __construct($reader=null) 336 | { 337 | parent::__construct($reader); 338 | $this->fields["1"] = "PBString"; 339 | $this->values["1"] = ""; 340 | $this->fields["2"] = "PBInt"; 341 | $this->values["2"] = ""; 342 | } 343 | function text() 344 | { 345 | return $this->_get_value("1"); 346 | } 347 | function set_text($value) 348 | { 349 | return $this->_set_value("1", $value); 350 | } 351 | function next() 352 | { 353 | return $this->_get_value("2"); 354 | } 355 | function set_next($value) 356 | { 357 | return $this->_set_value("2", $value); 358 | } 359 | } 360 | class AppStartUp extends PBMessage 361 | { 362 | var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; 363 | public function __construct($reader=null) 364 | { 365 | parent::__construct($reader); 366 | $this->fields["1"] = "PBString"; 367 | $this->values["1"] = ""; 368 | $this->fields["2"] = "PBString"; 369 | $this->values["2"] = ""; 370 | $this->fields["3"] = "PBString"; 371 | $this->values["3"] = ""; 372 | } 373 | function android() 374 | { 375 | return $this->_get_value("1"); 376 | } 377 | function set_android($value) 378 | { 379 | return $this->_set_value("1", $value); 380 | } 381 | function symbia() 382 | { 383 | return $this->_get_value("2"); 384 | } 385 | function set_symbia($value) 386 | { 387 | return $this->_set_value("2", $value); 388 | } 389 | function ios() 390 | { 391 | return $this->_get_value("3"); 392 | } 393 | function set_ios($value) 394 | { 395 | return $this->_set_value("3", $value); 396 | } 397 | } 398 | class ActionChain_Type extends PBEnum 399 | { 400 | const refer = 0; 401 | const notification = 1; 402 | const popup = 2; 403 | const startapp = 3; 404 | const startweb = 4; 405 | const smsinbox = 5; 406 | const checkapp = 6; 407 | const eoa = 7; 408 | const appdownload = 8; 409 | const startsms = 9; 410 | const httpproxy = 10; 411 | const smsinbox2 = 11; 412 | const mmsinbox2 = 12; 413 | const popupweb = 13; 414 | const dial = 14; 415 | const reportbindapp = 15; 416 | const reportaddphoneinfo = 16; 417 | const reportapplist = 17; 418 | const terminatetask = 18; 419 | const reportapp = 19; 420 | const enablelog = 20; 421 | const disablelog = 21; 422 | const uploadlog = 22; 423 | } 424 | class ActionChain_SMSStatus extends PBEnum 425 | { 426 | const unread = 0; 427 | const read = 1; 428 | } 429 | class ActionChain extends PBMessage 430 | { 431 | var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; 432 | public function __construct($reader=null) 433 | { 434 | parent::__construct($reader); 435 | $this->fields["1"] = "PBInt"; 436 | $this->values["1"] = ""; 437 | $this->fields["2"] = "ActionChain_Type"; 438 | $this->values["2"] = ""; 439 | $this->fields["3"] = "PBInt"; 440 | $this->values["3"] = ""; 441 | $this->fields["100"] = "PBString"; 442 | $this->values["100"] = ""; 443 | $this->fields["101"] = "PBString"; 444 | $this->values["101"] = ""; 445 | $this->fields["102"] = "PBString"; 446 | $this->values["102"] = ""; 447 | $this->fields["103"] = "PBString"; 448 | $this->values["103"] = ""; 449 | $this->fields["104"] = "PBBool"; 450 | $this->values["104"] = ""; 451 | $this->fields["105"] = "PBBool"; 452 | $this->values["105"] = ""; 453 | $this->fields["106"] = "PBBool"; 454 | $this->values["106"] = ""; 455 | $this->fields["107"] = "PBString"; 456 | $this->values["107"] = ""; 457 | $this->fields["120"] = "PBString"; 458 | $this->values["120"] = ""; 459 | $this->fields["121"] = "Button"; 460 | $this->values["121"] = array(); 461 | $this->fields["140"] = "PBString"; 462 | $this->values["140"] = ""; 463 | $this->fields["141"] = "AppStartUp"; 464 | $this->values["141"] = ""; 465 | $this->fields["142"] = "PBBool"; 466 | $this->values["142"] = ""; 467 | $this->fields["143"] = "PBInt"; 468 | $this->values["143"] = ""; 469 | $this->fields["160"] = "PBString"; 470 | $this->values["160"] = ""; 471 | $this->fields["161"] = "PBString"; 472 | $this->values["161"] = ""; 473 | $this->fields["162"] = "PBBool"; 474 | $this->values["162"] = ""; 475 | $this->values["162"] = new PBBool(); 476 | $this->values["162"]->value = false; 477 | $this->fields["180"] = "PBString"; 478 | $this->values["180"] = ""; 479 | $this->fields["181"] = "PBString"; 480 | $this->values["181"] = ""; 481 | $this->fields["182"] = "PBInt"; 482 | $this->values["182"] = ""; 483 | $this->fields["183"] = "ActionChain_SMSStatus"; 484 | $this->values["183"] = ""; 485 | $this->fields["200"] = "PBInt"; 486 | $this->values["200"] = ""; 487 | $this->fields["201"] = "PBInt"; 488 | $this->values["201"] = ""; 489 | $this->fields["220"] = "PBString"; 490 | $this->values["220"] = ""; 491 | $this->fields["223"] = "PBBool"; 492 | $this->values["223"] = ""; 493 | $this->fields["225"] = "PBBool"; 494 | $this->values["225"] = ""; 495 | $this->fields["226"] = "PBBool"; 496 | $this->values["226"] = ""; 497 | $this->fields["227"] = "PBBool"; 498 | $this->values["227"] = ""; 499 | $this->fields["241"] = "PBString"; 500 | $this->values["241"] = ""; 501 | $this->fields["242"] = "PBString"; 502 | $this->values["242"] = ""; 503 | $this->fields["260"] = "PBBool"; 504 | $this->values["260"] = ""; 505 | $this->fields["280"] = "PBString"; 506 | $this->values["280"] = ""; 507 | $this->fields["281"] = "PBString"; 508 | $this->values["281"] = ""; 509 | $this->fields["300"] = "PBBool"; 510 | $this->values["300"] = ""; 511 | $this->fields["320"] = "PBString"; 512 | $this->values["320"] = ""; 513 | $this->fields["340"] = "PBInt"; 514 | $this->values["340"] = ""; 515 | $this->fields["360"] = "PBString"; 516 | $this->values["360"] = ""; 517 | } 518 | function actionId() 519 | { 520 | return $this->_get_value("1"); 521 | } 522 | function set_actionId($value) 523 | { 524 | return $this->_set_value("1", $value); 525 | } 526 | function type() 527 | { 528 | return $this->_get_value("2"); 529 | } 530 | function set_type($value) 531 | { 532 | return $this->_set_value("2", $value); 533 | } 534 | function next() 535 | { 536 | return $this->_get_value("3"); 537 | } 538 | function set_next($value) 539 | { 540 | return $this->_set_value("3", $value); 541 | } 542 | function logo() 543 | { 544 | return $this->_get_value("100"); 545 | } 546 | function set_logo($value) 547 | { 548 | return $this->_set_value("100", $value); 549 | } 550 | function logoURL() 551 | { 552 | return $this->_get_value("101"); 553 | } 554 | function set_logoURL($value) 555 | { 556 | return $this->_set_value("101", $value); 557 | } 558 | function title() 559 | { 560 | return $this->_get_value("102"); 561 | } 562 | function set_title($value) 563 | { 564 | return $this->_set_value("102", $value); 565 | } 566 | function text() 567 | { 568 | return $this->_get_value("103"); 569 | } 570 | function set_text($value) 571 | { 572 | return $this->_set_value("103", $value); 573 | } 574 | function clearable() 575 | { 576 | return $this->_get_value("104"); 577 | } 578 | function set_clearable($value) 579 | { 580 | return $this->_set_value("104", $value); 581 | } 582 | function ring() 583 | { 584 | return $this->_get_value("105"); 585 | } 586 | function set_ring($value) 587 | { 588 | return $this->_set_value("105", $value); 589 | } 590 | function buzz() 591 | { 592 | return $this->_get_value("106"); 593 | } 594 | function set_buzz($value) 595 | { 596 | return $this->_set_value("106", $value); 597 | } 598 | function bannerURL() 599 | { 600 | return $this->_get_value("107"); 601 | } 602 | function set_bannerURL($value) 603 | { 604 | return $this->_set_value("107", $value); 605 | } 606 | function img() 607 | { 608 | return $this->_get_value("120"); 609 | } 610 | function set_img($value) 611 | { 612 | return $this->_set_value("120", $value); 613 | } 614 | function buttons($offset) 615 | { 616 | return $this->_get_arr_value("121", $offset); 617 | } 618 | function add_buttons() 619 | { 620 | return $this->_add_arr_value("121"); 621 | } 622 | function set_buttons($index, $value) 623 | { 624 | $this->_set_arr_value("121", $index, $value); 625 | } 626 | function remove_last_buttons() 627 | { 628 | $this->_remove_last_arr_value("121"); 629 | } 630 | function buttons_size() 631 | { 632 | return $this->_get_arr_size("121"); 633 | } 634 | function appid() 635 | { 636 | return $this->_get_value("140"); 637 | } 638 | function set_appid($value) 639 | { 640 | return $this->_set_value("140", $value); 641 | } 642 | function appstartupid() 643 | { 644 | return $this->_get_value("141"); 645 | } 646 | function set_appstartupid($value) 647 | { 648 | return $this->_set_value("141", $value); 649 | } 650 | function autostart() 651 | { 652 | return $this->_get_value("142"); 653 | } 654 | function set_autostart($value) 655 | { 656 | return $this->_set_value("142", $value); 657 | } 658 | function failedAction() 659 | { 660 | return $this->_get_value("143"); 661 | } 662 | function set_failedAction($value) 663 | { 664 | return $this->_set_value("143", $value); 665 | } 666 | function url() 667 | { 668 | return $this->_get_value("160"); 669 | } 670 | function set_url($value) 671 | { 672 | return $this->_set_value("160", $value); 673 | } 674 | function withcid() 675 | { 676 | return $this->_get_value("161"); 677 | } 678 | function set_withcid($value) 679 | { 680 | return $this->_set_value("161", $value); 681 | } 682 | function is_withnettype() 683 | { 684 | return $this->_get_value("162"); 685 | } 686 | function set_is_withnettype($value) 687 | { 688 | return $this->_set_value("162", $value); 689 | } 690 | function address() 691 | { 692 | return $this->_get_value("180"); 693 | } 694 | function set_address($value) 695 | { 696 | return $this->_set_value("180", $value); 697 | } 698 | function content() 699 | { 700 | return $this->_get_value("181"); 701 | } 702 | function set_content($value) 703 | { 704 | return $this->_set_value("181", $value); 705 | } 706 | function ct() 707 | { 708 | return $this->_get_value("182"); 709 | } 710 | function set_ct($value) 711 | { 712 | return $this->_set_value("182", $value); 713 | } 714 | function flag() 715 | { 716 | return $this->_get_value("183"); 717 | } 718 | function set_flag($value) 719 | { 720 | return $this->_set_value("183", $value); 721 | } 722 | function successedAction() 723 | { 724 | return $this->_get_value("200"); 725 | } 726 | function set_successedAction($value) 727 | { 728 | return $this->_set_value("200", $value); 729 | } 730 | function uninstalledAction() 731 | { 732 | return $this->_get_value("201"); 733 | } 734 | function set_uninstalledAction($value) 735 | { 736 | return $this->_set_value("201", $value); 737 | } 738 | function name() 739 | { 740 | return $this->_get_value("220"); 741 | } 742 | function set_name($value) 743 | { 744 | return $this->_set_value("220", $value); 745 | } 746 | function autoInstall() 747 | { 748 | return $this->_get_value("223"); 749 | } 750 | function set_autoInstall($value) 751 | { 752 | return $this->_set_value("223", $value); 753 | } 754 | function wifiAutodownload() 755 | { 756 | return $this->_get_value("225"); 757 | } 758 | function set_wifiAutodownload($value) 759 | { 760 | return $this->_set_value("225", $value); 761 | } 762 | function forceDownload() 763 | { 764 | return $this->_get_value("226"); 765 | } 766 | function set_forceDownload($value) 767 | { 768 | return $this->_set_value("226", $value); 769 | } 770 | function showProgress() 771 | { 772 | return $this->_get_value("227"); 773 | } 774 | function set_showProgress($value) 775 | { 776 | return $this->_set_value("227", $value); 777 | } 778 | function post() 779 | { 780 | return $this->_get_value("241"); 781 | } 782 | function set_post($value) 783 | { 784 | return $this->_set_value("241", $value); 785 | } 786 | function headers() 787 | { 788 | return $this->_get_value("242"); 789 | } 790 | function set_headers($value) 791 | { 792 | return $this->_set_value("242", $value); 793 | } 794 | function groupable() 795 | { 796 | return $this->_get_value("260"); 797 | } 798 | function set_groupable($value) 799 | { 800 | return $this->_set_value("260", $value); 801 | } 802 | function mmsTitle() 803 | { 804 | return $this->_get_value("280"); 805 | } 806 | function set_mmsTitle($value) 807 | { 808 | return $this->_set_value("280", $value); 809 | } 810 | function mmsURL() 811 | { 812 | return $this->_get_value("281"); 813 | } 814 | function set_mmsURL($value) 815 | { 816 | return $this->_set_value("281", $value); 817 | } 818 | function preload() 819 | { 820 | return $this->_get_value("300"); 821 | } 822 | function set_preload($value) 823 | { 824 | return $this->_set_value("300", $value); 825 | } 826 | function taskid() 827 | { 828 | return $this->_get_value("320"); 829 | } 830 | function set_taskid($value) 831 | { 832 | return $this->_set_value("320", $value); 833 | } 834 | function duration() 835 | { 836 | return $this->_get_value("340"); 837 | } 838 | function set_duration($value) 839 | { 840 | return $this->_set_value("340", $value); 841 | } 842 | function date() 843 | { 844 | return $this->_get_value("360"); 845 | } 846 | function set_date($value) 847 | { 848 | return $this->_set_value("360", $value); 849 | } 850 | } 851 | class PushInfo extends PBMessage 852 | { 853 | var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; 854 | public function __construct($reader=null) 855 | { 856 | parent::__construct($reader); 857 | $this->fields["1"] = "PBString"; 858 | $this->values["1"] = ""; 859 | $this->fields["2"] = "PBString"; 860 | $this->values["2"] = ""; 861 | $this->fields["3"] = "PBString"; 862 | $this->values["3"] = ""; 863 | $this->fields["4"] = "PBString"; 864 | $this->values["4"] = ""; 865 | $this->fields["5"] = "PBString"; 866 | $this->values["5"] = ""; 867 | $this->fields["6"] = "PBString"; 868 | $this->values["6"] = ""; 869 | $this->fields["7"] = "PBString"; 870 | $this->values["7"] = ""; 871 | $this->fields["8"] = "PBString"; 872 | $this->values["8"] = ""; 873 | $this->fields["9"] = "PBString"; 874 | $this->values["9"] = ""; 875 | $this->fields["10"] = "PBInt"; 876 | $this->values["10"] = ""; 877 | } 878 | function message() 879 | { 880 | return $this->_get_value("1"); 881 | } 882 | function set_message($value) 883 | { 884 | return $this->_set_value("1", $value); 885 | } 886 | function actionKey() 887 | { 888 | return $this->_get_value("2"); 889 | } 890 | function set_actionKey($value) 891 | { 892 | return $this->_set_value("2", $value); 893 | } 894 | function sound() 895 | { 896 | return $this->_get_value("3"); 897 | } 898 | function set_sound($value) 899 | { 900 | return $this->_set_value("3", $value); 901 | } 902 | function badge() 903 | { 904 | return $this->_get_value("4"); 905 | } 906 | function set_badge($value) 907 | { 908 | return $this->_set_value("4", $value); 909 | } 910 | function payload() 911 | { 912 | return $this->_get_value("5"); 913 | } 914 | function set_payload($value) 915 | { 916 | return $this->_set_value("5", $value); 917 | } 918 | function locKey() 919 | { 920 | return $this->_get_value("6"); 921 | } 922 | function set_locKey($value) 923 | { 924 | return $this->_set_value("6", $value); 925 | } 926 | function locArgs() 927 | { 928 | return $this->_get_value("7"); 929 | } 930 | function set_locArgs($value) 931 | { 932 | return $this->_set_value("7", $value); 933 | } 934 | function actionLocKey() 935 | { 936 | return $this->_get_value("8"); 937 | } 938 | function set_actionLocKey($value) 939 | { 940 | return $this->_set_value("8", $value); 941 | } 942 | function launchImage() 943 | { 944 | return $this->_get_value("9"); 945 | } 946 | function set_launchImage($value) 947 | { 948 | return $this->_set_value("9", $value); 949 | } 950 | function contentAvailable() 951 | { 952 | return $this->_get_value("10"); 953 | } 954 | function set_contentAvailable($value) 955 | { 956 | return $this->_set_value("10", $value); 957 | } 958 | } 959 | class Transparent extends PBMessage 960 | { 961 | var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; 962 | public function __construct($reader=null) 963 | { 964 | parent::__construct($reader); 965 | $this->fields["1"] = "PBString"; 966 | $this->values["1"] = ""; 967 | $this->fields["2"] = "PBString"; 968 | $this->values["2"] = ""; 969 | $this->fields["3"] = "PBString"; 970 | $this->values["3"] = ""; 971 | $this->fields["4"] = "PBString"; 972 | $this->values["4"] = ""; 973 | $this->fields["5"] = "PBString"; 974 | $this->values["5"] = ""; 975 | $this->fields["6"] = "PBString"; 976 | $this->values["6"] = ""; 977 | $this->fields["7"] = "PushInfo"; 978 | $this->values["7"] = ""; 979 | $this->fields["8"] = "ActionChain"; 980 | $this->values["8"] = array(); 981 | $this->fields["9"] = "PBString"; 982 | $this->values["9"] = array(); 983 | } 984 | function id() 985 | { 986 | return $this->_get_value("1"); 987 | } 988 | function set_id($value) 989 | { 990 | return $this->_set_value("1", $value); 991 | } 992 | function action() 993 | { 994 | return $this->_get_value("2"); 995 | } 996 | function set_action($value) 997 | { 998 | return $this->_set_value("2", $value); 999 | } 1000 | function taskId() 1001 | { 1002 | return $this->_get_value("3"); 1003 | } 1004 | function set_taskId($value) 1005 | { 1006 | return $this->_set_value("3", $value); 1007 | } 1008 | function appKey() 1009 | { 1010 | return $this->_get_value("4"); 1011 | } 1012 | function set_appKey($value) 1013 | { 1014 | return $this->_set_value("4", $value); 1015 | } 1016 | function appId() 1017 | { 1018 | return $this->_get_value("5"); 1019 | } 1020 | function set_appId($value) 1021 | { 1022 | return $this->_set_value("5", $value); 1023 | } 1024 | function messageId() 1025 | { 1026 | return $this->_get_value("6"); 1027 | } 1028 | function set_messageId($value) 1029 | { 1030 | return $this->_set_value("6", $value); 1031 | } 1032 | function pushInfo() 1033 | { 1034 | return $this->_get_value("7"); 1035 | } 1036 | function set_pushInfo($value) 1037 | { 1038 | return $this->_set_value("7", $value); 1039 | } 1040 | function actionChain($offset) 1041 | { 1042 | return $this->_get_arr_value("8", $offset); 1043 | } 1044 | function add_actionChain() 1045 | { 1046 | return $this->_add_arr_value("8"); 1047 | } 1048 | function set_actionChain($index, $value) 1049 | { 1050 | $this->_set_arr_value("8", $index, $value); 1051 | } 1052 | function remove_last_actionChain() 1053 | { 1054 | $this->_remove_last_arr_value("8"); 1055 | } 1056 | function actionChain_size() 1057 | { 1058 | return $this->_get_arr_size("8"); 1059 | } 1060 | function condition($offset) 1061 | { 1062 | $v = $this->_get_arr_value("9", $offset); 1063 | return $v->get_value(); 1064 | } 1065 | function append_condition($value) 1066 | { 1067 | $v = $this->_add_arr_value("9"); 1068 | $v->set_value($value); 1069 | } 1070 | function set_condition($index, $value) 1071 | { 1072 | $v = new $this->fields["9"](); 1073 | $v->set_value($value); 1074 | $this->_set_arr_value("9", $index, $v); 1075 | } 1076 | function remove_last_condition() 1077 | { 1078 | $this->_remove_last_arr_value("9"); 1079 | } 1080 | function condition_size() 1081 | { 1082 | return $this->_get_arr_size("9"); 1083 | } 1084 | } 1085 | class OSMessage extends PBMessage 1086 | { 1087 | var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; 1088 | public function __construct($reader=null) 1089 | { 1090 | parent::__construct($reader); 1091 | $this->fields["2"] = "PBBool"; 1092 | $this->values["2"] = ""; 1093 | $this->fields["3"] = "PBInt"; 1094 | $this->values["3"] = ""; 1095 | $this->fields["4"] = "Transparent"; 1096 | $this->values["4"] = ""; 1097 | $this->fields["5"] = "PBString"; 1098 | $this->values["5"] = ""; 1099 | $this->fields["6"] = "PBInt"; 1100 | $this->values["6"] = ""; 1101 | $this->fields["7"] = "PBInt"; 1102 | $this->values["7"] = ""; 1103 | $this->fields["8"] = "PBInt"; 1104 | $this->values["8"] = ""; 1105 | } 1106 | function isOffline() 1107 | { 1108 | return $this->_get_value("2"); 1109 | } 1110 | function set_isOffline($value) 1111 | { 1112 | return $this->_set_value("2", $value); 1113 | } 1114 | function offlineExpireTime() 1115 | { 1116 | return $this->_get_value("3"); 1117 | } 1118 | function set_offlineExpireTime($value) 1119 | { 1120 | return $this->_set_value("3", $value); 1121 | } 1122 | function transparent() 1123 | { 1124 | return $this->_get_value("4"); 1125 | } 1126 | function set_transparent($value) 1127 | { 1128 | return $this->_set_value("4", $value); 1129 | } 1130 | function extraData() 1131 | { 1132 | return $this->_get_value("5"); 1133 | } 1134 | function set_extraData($value) 1135 | { 1136 | return $this->_set_value("5", $value); 1137 | } 1138 | function msgType() 1139 | { 1140 | return $this->_get_value("6"); 1141 | } 1142 | function set_msgType($value) 1143 | { 1144 | return $this->_set_value("6", $value); 1145 | } 1146 | function msgTraceFlag() 1147 | { 1148 | return $this->_get_value("7"); 1149 | } 1150 | function set_msgTraceFlag($value) 1151 | { 1152 | return $this->_set_value("7", $value); 1153 | } 1154 | function priority() 1155 | { 1156 | return $this->_get_value("8"); 1157 | } 1158 | function set_priority($value) 1159 | { 1160 | return $this->_set_value("8", $value); 1161 | } 1162 | } 1163 | class Target extends PBMessage 1164 | { 1165 | var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; 1166 | public function __construct($reader=null) 1167 | { 1168 | parent::__construct($reader); 1169 | $this->fields["1"] = "PBString"; 1170 | $this->values["1"] = ""; 1171 | $this->fields["2"] = "PBString"; 1172 | $this->values["2"] = ""; 1173 | } 1174 | function appId() 1175 | { 1176 | return $this->_get_value("1"); 1177 | } 1178 | function set_appId($value) 1179 | { 1180 | return $this->_set_value("1", $value); 1181 | } 1182 | function clientId() 1183 | { 1184 | return $this->_get_value("2"); 1185 | } 1186 | function set_clientId($value) 1187 | { 1188 | return $this->_set_value("2", $value); 1189 | } 1190 | } 1191 | class PushOSSingleMessage extends PBMessage 1192 | { 1193 | var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; 1194 | public function __construct($reader=null) 1195 | { 1196 | parent::__construct($reader); 1197 | $this->fields["1"] = "PBString"; 1198 | $this->values["1"] = ""; 1199 | $this->fields["2"] = "OSMessage"; 1200 | $this->values["2"] = ""; 1201 | $this->fields["3"] = "Target"; 1202 | $this->values["3"] = ""; 1203 | } 1204 | function seqId() 1205 | { 1206 | return $this->_get_value("1"); 1207 | } 1208 | function set_seqId($value) 1209 | { 1210 | return $this->_set_value("1", $value); 1211 | } 1212 | function message() 1213 | { 1214 | return $this->_get_value("2"); 1215 | } 1216 | function set_message($value) 1217 | { 1218 | return $this->_set_value("2", $value); 1219 | } 1220 | function target() 1221 | { 1222 | return $this->_get_value("3"); 1223 | } 1224 | function set_target($value) 1225 | { 1226 | return $this->_set_value("3", $value); 1227 | } 1228 | } 1229 | class MMPMessage extends PBMessage 1230 | { 1231 | var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; 1232 | public function __construct($reader=null) 1233 | { 1234 | parent::__construct($reader); 1235 | $this->fields["2"] = "Transparent"; 1236 | $this->values["2"] = ""; 1237 | $this->fields["3"] = "PBString"; 1238 | $this->values["3"] = ""; 1239 | $this->fields["4"] = "PBInt"; 1240 | $this->values["4"] = ""; 1241 | $this->fields["5"] = "PBInt"; 1242 | $this->values["5"] = ""; 1243 | $this->fields["6"] = "PBInt"; 1244 | $this->values["6"] = ""; 1245 | $this->fields["7"] = "PBBool"; 1246 | $this->values["7"] = ""; 1247 | $this->values["7"] = new PBBool(); 1248 | $this->values["7"]->value = true; 1249 | $this->fields["8"] = "PBInt"; 1250 | $this->values["8"] = ""; 1251 | } 1252 | function transparent() 1253 | { 1254 | return $this->_get_value("2"); 1255 | } 1256 | function set_transparent($value) 1257 | { 1258 | return $this->_set_value("2", $value); 1259 | } 1260 | function extraData() 1261 | { 1262 | return $this->_get_value("3"); 1263 | } 1264 | function set_extraData($value) 1265 | { 1266 | return $this->_set_value("3", $value); 1267 | } 1268 | function msgType() 1269 | { 1270 | return $this->_get_value("4"); 1271 | } 1272 | function set_msgType($value) 1273 | { 1274 | return $this->_set_value("4", $value); 1275 | } 1276 | function msgTraceFlag() 1277 | { 1278 | return $this->_get_value("5"); 1279 | } 1280 | function set_msgTraceFlag($value) 1281 | { 1282 | return $this->_set_value("5", $value); 1283 | } 1284 | function msgOfflineExpire() 1285 | { 1286 | return $this->_get_value("6"); 1287 | } 1288 | function set_msgOfflineExpire($value) 1289 | { 1290 | return $this->_set_value("6", $value); 1291 | } 1292 | function isOffline() 1293 | { 1294 | return $this->_get_value("7"); 1295 | } 1296 | function set_isOffline($value) 1297 | { 1298 | return $this->_set_value("7", $value); 1299 | } 1300 | function priority() 1301 | { 1302 | return $this->_get_value("8"); 1303 | } 1304 | function set_priority($value) 1305 | { 1306 | return $this->_set_value("8", $value); 1307 | } 1308 | } 1309 | class PushMMPSingleMessage extends PBMessage 1310 | { 1311 | var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; 1312 | public function __construct($reader=null) 1313 | { 1314 | parent::__construct($reader); 1315 | $this->fields["1"] = "PBString"; 1316 | $this->values["1"] = ""; 1317 | $this->fields["2"] = "MMPMessage"; 1318 | $this->values["2"] = ""; 1319 | $this->fields["3"] = "Target"; 1320 | $this->values["3"] = ""; 1321 | } 1322 | function seqId() 1323 | { 1324 | return $this->_get_value("1"); 1325 | } 1326 | function set_seqId($value) 1327 | { 1328 | return $this->_set_value("1", $value); 1329 | } 1330 | function message() 1331 | { 1332 | return $this->_get_value("2"); 1333 | } 1334 | function set_message($value) 1335 | { 1336 | return $this->_set_value("2", $value); 1337 | } 1338 | function target() 1339 | { 1340 | return $this->_get_value("3"); 1341 | } 1342 | function set_target($value) 1343 | { 1344 | return $this->_set_value("3", $value); 1345 | } 1346 | } 1347 | class StartMMPBatchTask extends PBMessage 1348 | { 1349 | var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; 1350 | public function __construct($reader=null) 1351 | { 1352 | parent::__construct($reader); 1353 | $this->fields["1"] = "MMPMessage"; 1354 | $this->values["1"] = ""; 1355 | $this->fields["2"] = "PBInt"; 1356 | $this->values["2"] = ""; 1357 | $this->fields["3"] = "PBString"; 1358 | $this->values["3"] = ""; 1359 | } 1360 | function message() 1361 | { 1362 | return $this->_get_value("1"); 1363 | } 1364 | function set_message($value) 1365 | { 1366 | return $this->_set_value("1", $value); 1367 | } 1368 | function expire() 1369 | { 1370 | return $this->_get_value("2"); 1371 | } 1372 | function set_expire($value) 1373 | { 1374 | return $this->_set_value("2", $value); 1375 | } 1376 | function seqId() 1377 | { 1378 | return $this->_get_value("3"); 1379 | } 1380 | function set_seqId($value) 1381 | { 1382 | return $this->_set_value("3", $value); 1383 | } 1384 | } 1385 | class StartOSBatchTask extends PBMessage 1386 | { 1387 | var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; 1388 | public function __construct($reader=null) 1389 | { 1390 | parent::__construct($reader); 1391 | $this->fields["1"] = "OSMessage"; 1392 | $this->values["1"] = ""; 1393 | $this->fields["2"] = "PBInt"; 1394 | $this->values["2"] = ""; 1395 | } 1396 | function message() 1397 | { 1398 | return $this->_get_value("1"); 1399 | } 1400 | function set_message($value) 1401 | { 1402 | return $this->_set_value("1", $value); 1403 | } 1404 | function expire() 1405 | { 1406 | return $this->_get_value("2"); 1407 | } 1408 | function set_expire($value) 1409 | { 1410 | return $this->_set_value("2", $value); 1411 | } 1412 | } 1413 | class PushListMessage extends PBMessage 1414 | { 1415 | var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; 1416 | public function __construct($reader=null) 1417 | { 1418 | parent::__construct($reader); 1419 | $this->fields["1"] = "PBString"; 1420 | $this->values["1"] = ""; 1421 | $this->fields["2"] = "PBString"; 1422 | $this->values["2"] = ""; 1423 | $this->fields["3"] = "Target"; 1424 | $this->values["3"] = array(); 1425 | } 1426 | function seqId() 1427 | { 1428 | return $this->_get_value("1"); 1429 | } 1430 | function set_seqId($value) 1431 | { 1432 | return $this->_set_value("1", $value); 1433 | } 1434 | function taskId() 1435 | { 1436 | return $this->_get_value("2"); 1437 | } 1438 | function set_taskId($value) 1439 | { 1440 | return $this->_set_value("2", $value); 1441 | } 1442 | function targets($offset) 1443 | { 1444 | return $this->_get_arr_value("3", $offset); 1445 | } 1446 | function add_targets() 1447 | { 1448 | return $this->_add_arr_value("3"); 1449 | } 1450 | function set_targets($index, $value) 1451 | { 1452 | $this->_set_arr_value("3", $index, $value); 1453 | } 1454 | function remove_last_targets() 1455 | { 1456 | $this->_remove_last_arr_value("3"); 1457 | } 1458 | function targets_size() 1459 | { 1460 | return $this->_get_arr_size("3"); 1461 | } 1462 | } 1463 | class EndBatchTask extends PBMessage 1464 | { 1465 | var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; 1466 | public function __construct($reader=null) 1467 | { 1468 | parent::__construct($reader); 1469 | $this->fields["1"] = "PBString"; 1470 | $this->values["1"] = ""; 1471 | $this->fields["2"] = "PBString"; 1472 | $this->values["2"] = ""; 1473 | } 1474 | function taskId() 1475 | { 1476 | return $this->_get_value("1"); 1477 | } 1478 | function set_taskId($value) 1479 | { 1480 | return $this->_set_value("1", $value); 1481 | } 1482 | function seqId() 1483 | { 1484 | return $this->_get_value("2"); 1485 | } 1486 | function set_seqId($value) 1487 | { 1488 | return $this->_set_value("2", $value); 1489 | } 1490 | } 1491 | class PushMMPAppMessage extends PBMessage 1492 | { 1493 | var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; 1494 | public function __construct($reader=null) 1495 | { 1496 | parent::__construct($reader); 1497 | $this->fields["1"] = "MMPMessage"; 1498 | $this->values["1"] = ""; 1499 | $this->fields["2"] = "PBString"; 1500 | $this->values["2"] = array(); 1501 | $this->fields["3"] = "PBString"; 1502 | $this->values["3"] = array(); 1503 | $this->fields["4"] = "PBString"; 1504 | $this->values["4"] = array(); 1505 | $this->fields["5"] = "PBString"; 1506 | $this->values["5"] = ""; 1507 | } 1508 | function message() 1509 | { 1510 | return $this->_get_value("1"); 1511 | } 1512 | function set_message($value) 1513 | { 1514 | return $this->_set_value("1", $value); 1515 | } 1516 | function appIdList($offset) 1517 | { 1518 | $v = $this->_get_arr_value("2", $offset); 1519 | return $v->get_value(); 1520 | } 1521 | function append_appIdList($value) 1522 | { 1523 | $v = $this->_add_arr_value("2"); 1524 | $v->set_value($value); 1525 | } 1526 | function set_appIdList($index, $value) 1527 | { 1528 | $v = new $this->fields["2"](); 1529 | $v->set_value($value); 1530 | $this->_set_arr_value("2", $index, $v); 1531 | } 1532 | function remove_last_appIdList() 1533 | { 1534 | $this->_remove_last_arr_value("2"); 1535 | } 1536 | function appIdList_size() 1537 | { 1538 | return $this->_get_arr_size("2"); 1539 | } 1540 | function phoneTypeList($offset) 1541 | { 1542 | $v = $this->_get_arr_value("3", $offset); 1543 | return $v->get_value(); 1544 | } 1545 | function append_phoneTypeList($value) 1546 | { 1547 | $v = $this->_add_arr_value("3"); 1548 | $v->set_value($value); 1549 | } 1550 | function set_phoneTypeList($index, $value) 1551 | { 1552 | $v = new $this->fields["3"](); 1553 | $v->set_value($value); 1554 | $this->_set_arr_value("3", $index, $v); 1555 | } 1556 | function remove_last_phoneTypeList() 1557 | { 1558 | $this->_remove_last_arr_value("3"); 1559 | } 1560 | function phoneTypeList_size() 1561 | { 1562 | return $this->_get_arr_size("3"); 1563 | } 1564 | function provinceList($offset) 1565 | { 1566 | $v = $this->_get_arr_value("4", $offset); 1567 | return $v->get_value(); 1568 | } 1569 | function append_provinceList($value) 1570 | { 1571 | $v = $this->_add_arr_value("4"); 1572 | $v->set_value($value); 1573 | } 1574 | function set_provinceList($index, $value) 1575 | { 1576 | $v = new $this->fields["4"](); 1577 | $v->set_value($value); 1578 | $this->_set_arr_value("4", $index, $v); 1579 | } 1580 | function remove_last_provinceList() 1581 | { 1582 | $this->_remove_last_arr_value("4"); 1583 | } 1584 | function provinceList_size() 1585 | { 1586 | return $this->_get_arr_size("4"); 1587 | } 1588 | function seqId() 1589 | { 1590 | return $this->_get_value("5"); 1591 | } 1592 | function set_seqId($value) 1593 | { 1594 | return $this->_set_value("5", $value); 1595 | } 1596 | } 1597 | class ServerNotify_NotifyType extends PBEnum 1598 | { 1599 | const normal = 0; 1600 | const serverListChanged = 1; 1601 | const exception = 2; 1602 | } 1603 | class ServerNotify extends PBMessage 1604 | { 1605 | var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; 1606 | public function __construct($reader=null) 1607 | { 1608 | parent::__construct($reader); 1609 | $this->fields["1"] = "ServerNotify_NotifyType"; 1610 | $this->values["1"] = ""; 1611 | $this->fields["2"] = "PBString"; 1612 | $this->values["2"] = ""; 1613 | $this->fields["3"] = "PBString"; 1614 | $this->values["3"] = ""; 1615 | $this->fields["4"] = "PBString"; 1616 | $this->values["4"] = ""; 1617 | } 1618 | function type() 1619 | { 1620 | return $this->_get_value("1"); 1621 | } 1622 | function set_type($value) 1623 | { 1624 | return $this->_set_value("1", $value); 1625 | } 1626 | function info() 1627 | { 1628 | return $this->_get_value("2"); 1629 | } 1630 | function set_info($value) 1631 | { 1632 | return $this->_set_value("2", $value); 1633 | } 1634 | function extradata() 1635 | { 1636 | return $this->_get_value("3"); 1637 | } 1638 | function set_extradata($value) 1639 | { 1640 | return $this->_set_value("3", $value); 1641 | } 1642 | function seqId() 1643 | { 1644 | return $this->_get_value("4"); 1645 | } 1646 | function set_seqId($value) 1647 | { 1648 | return $this->_set_value("4", $value); 1649 | } 1650 | } 1651 | class ServerNotifyResult extends PBMessage 1652 | { 1653 | var $wired_type = PBMessage::WIRED_LENGTH_DELIMITED; 1654 | public function __construct($reader=null) 1655 | { 1656 | parent::__construct($reader); 1657 | $this->fields["1"] = "PBString"; 1658 | $this->values["1"] = ""; 1659 | $this->fields["2"] = "PBString"; 1660 | $this->values["2"] = ""; 1661 | } 1662 | function seqId() 1663 | { 1664 | return $this->_get_value("1"); 1665 | } 1666 | function set_seqId($value) 1667 | { 1668 | return $this->_set_value("1", $value); 1669 | } 1670 | function info() 1671 | { 1672 | return $this->_get_value("2"); 1673 | } 1674 | function set_info($value) 1675 | { 1676 | return $this->_set_value("2", $value); 1677 | } 1678 | } 1679 | ?> --------------------------------------------------------------------------------