5 Star 14 Fork 7

华为移动服务 / hms-push-serverdemo-php

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README_ZH.md 4.15 KB
一键复制 编辑 原始数据 按行查看 历史
HMSPushKit 提交于 2023-06-28 07:59 . update README_ZH.md.

华为推送服务服务端PHP示例代码

English | 中文

目录

简介

PHP示例代码对华为推送服务(HUAWEI Push Kit)服务端接口进行封装,包含丰富的示例程序,方便您参考或直接使用。 示例代码主要包括以下组成:

包名 说明
examples 示例代码文件,每个PHP文件都可以独立运行
push_admin 推送服务的服务端接口封装包

安装

使用本示例代码前,请确保您的设备上已安装PHP开发环境。

环境要求

本示例代码经过XAMPP (MySQL + PHP + PERL) 5.6.26开发套件调试。

配置

__construct方法包括如下参数:

参数 说明
appid 应用ID,从应用消息中获取
appsecret 应用访问密钥,从应用信息中获取
access_token 华为OAuth 2.0获取token的地址。具体请参考基于OAuth 2.0开放鉴权-客户端模式
hw_token_server 推送服务的访问地址。具体请参考推送服务-下行消息

示例代码

本示例代码以push_admin包中的Application结构体为入口。Application结构体中的核心方法完成了对推送服务服务端接口的调用。 Application包括如下方法:

方法 说明
push_send_msg 向设备发送消息
common_send_msg 订阅主题、退订主题、查询设备订阅的主题列表
__construc 构造函数,获取发送消息的关键数据

1. 发送Android透传消息

代码位置: examples/test_sample_push_passthrouth_msg.php

2. 发送Android通知栏消息

代码位置: examples/test_sample_push_notification_msg.php

3. 基于主题发送消息

代码位置: examples/test_sample_push_topic_msg.php

4. 基于条件发送消息

代码位置: examples/test_sample_push_condition_msg.php

5. 向华为快应用发送消息

代码位置: examples/test_sample_push_instantce_app_msg.php

6. 基于WebPush代理发送消息

代码位置: examples/test_sample_push_webpush_msg.php

7. 基于APNs代理发送消息

代码位置: examples/test_sample_apns_msg.php

8. 发送测试消息.

代码位置: examples/test_sample_test_push_msg.php

技术支持

如果您对HMS Core还处于评估阶段,可在Reddit社区获取关于HMS Core的最新讯息,并与其他开发者交流见解。

如果您对使用HMS示例代码有疑问,请尝试:

  • 开发过程遇到问题上Stack Overflow,在huawei-mobile-services标签下提问,有华为研发专家在线一对一解决您的问题。
  • 华为开发者论坛 HMS Core板块与其他开发者进行交流。

如果您在尝试示例代码中遇到问题,请向仓库提交issue,也欢迎您提交Pull Request

授权许可

华为推送服务PHP示例代码经过Apache License, version 2.0授权许可。

PHP
1
https://gitee.com/hms-core/hms-push-serverdemo-php.git
git@gitee.com:hms-core/hms-push-serverdemo-php.git
hms-core
hms-push-serverdemo-php
hms-push-serverdemo-php
master

搜索帮助