zoukankan      html  css  js  c++  java
  • 极光推送 PHP sdk

    <?php
    defined('IN_WZ') or exit('No direct script access allowed');
    /**
     * Created by PhpStorm.
     * User: 闲道人阿力
     * Date: 2016/9/7
     * Time: 14:34
     */
    require_once 'jpushsdk/autoload.php' ;
    use JPushClient as JPush;
    class WUZHI_jpushsdk
    {
    
    
    
    
        public function iospushbyid($registration_id,$alert){
            $app_key = '0ac1e4c4ca231bf1f4444401';
            $master_secret = '9e7f16b3eba0c3c694444425';
            // $registration_id = '1a0018970aa604e54f9';
    
            $client = new JPush($app_key, $master_secret);
    
    
    
            // 完整的推送示例,包含指定Platform,指定Alias,Tag,指定iOS,Android notification,指定Message等
            $result = $client->push()
                ->setPlatform(array('ios', 'android'))
                //->addAlias('alias1')
                //->addTag(array('tag1', 'tag2'))
                ->setNotificationAlert('Hi, JPush')
                ->addRegistrationId($registration_id)
                //->addAndroidNotification('Hi, android notification', 'notification title', 1, array("key1"=>"value1", "key2"=>"value2"))
                ->addIosNotification("Hi, iOS notification", 'iOS sound', 1999, true, 'iOS category', array("key1"=>"value1", "key2"=>"value2"))
                //->setMessage("msg content", 'msg title', 'type', array("key1"=>"value1", "key2"=>"value2"))
                ->setOptions(time(), 3600, null, true)
                ->send();
    
            echo 'Result=' . json_encode($result) ;
    
    
        }
    
    
        public function androidpushbyid($registration_id,$alert)
        {
    
    
    
    
            $app_key = '0ac1e4c4ca231bf1f4444401';
            $master_secret = '9e7f16b3eba0c3c44444425';
           // $registration_id = '1a0018970aa604e54f9';
    
            $client = new JPush($app_key, $master_secret);
    
            $push_payload = $client->push()
               ->setPlatform(array('android'))
                //->addAllAudience()
                ->addRegistrationId($registration_id)
                ->setNotificationAlert($alert)
    
    
                ;
    
    
    
            try {
                $response = $push_payload->send();
            }catch (JPushExceptionsAPIConnectionException $e) {
                // try something here
                print $e;
            } catch (JPushExceptionsAPIRequestException $e) {
                // try something here
                print $e;
            }
    
    
            print_r($response);
    
        }
    
    
    
    }
  • 相关阅读:
    发现勤洗手可以有效提高机械键盘的手感
    linux过滤文本中含有关键字的行
    Shell中$0、$1、$2含义
    流计算
    Java 版本tensorflow模型推理实现(基于bert命名实体、基于transform文本分类)
    bert文本分类模型保存为savedmodel方式
    修正数据到json格式
    实际应用中的词向量维度使用注意
    找出一组数据中重复数据
    快速进行词向量训练和读取
  • 原文地址:https://www.cnblogs.com/aliblogs/p/5850228.html
Copyright © 2011-2022 走看看