• Stars
    star
    524
  • Rank 81,606 (Top 2 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 10 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

JPush's officially supported PHP client library for accessing JPush APIs. 极光推送官方支持的 PHP 版本服务器端 SDK。

JPush API PHP Client

这是 JPush REST API 的 PHP 版本封装开发包,是由极光推送官方提供的,一般支持最新的 API 功能。

对应的 REST API 文档: https://docs.jiguang.cn/jpush/server/push/server_overview/

支持的 PHP 版本: 5.3.3 ~ 5.6.x, 7.x

若需要兼容 PHP 5.3.3 以下版本,可以使用 v3 分支的代码。 因为运行 Composer 需要 PHP 5.3.2+ 以上版本,所以其不提供 Composer 支持, 也可以点击链接下载 v3.4.x 版本源码。

Installation

使用 Composer 安装

  • 执行 $ php composer.phar install$ composer install 进行安装。

直接下载源码安装

直接下载源代码也是一种安装 SDK 的方法,不过因为有版本更新的维护问题,所以这种安装方式十分不推荐,但由于种种原因导致无法使用 Composer,所以我们也提供了这种情况下的备选方案。

  • 下载源代码包,解压到项目中
  • 在项目中引入 autoload:
require 'path_to_sdk/autoload.php';

Usage

初始化

use JPush\Client as JPush;
...
...

    $client = new JPush($app_key, $master_secret);

...

OR

$client = new \JPush\Client($app_key, $master_secret);

简单推送

$client->push()
    ->setPlatform('all')
    ->addAllAudience()
    ->setNotificationAlert('Hello, JPush')
    ->send();

异常处理

$pusher = $client->push();
$pusher->setPlatform('all');
$pusher->addAllAudience();
$pusher->setNotificationAlert('Hello, JPush');
try {
    $pusher->send();
} catch (\JPush\Exceptions\JPushException $e) {
    // try something else here
    print $e;
}

Examples

注意: 这只是使用样例, 不应该直接用于实际环境中!!

在下载的中的 examples 文件夹有简单示例代码, 开发者可以参考其中的样例快速了解该库的使用方法。

简单使用方法

先填写对应的appKey和masterSecret,可以额外设定Registration_id。

若要运行 push_example.php 中的示例代码:

# 假定当前目录为 JPush 源码所在的根目录
$ php examples/push_example.php

同时也可编辑相关的示例文件,更改参数查看执行效果

Testing

# 编辑 tests/bootstrap.php 文件,填入必须的变量值
# OR 设置相应的环境变量

# 运行全部测试用例
$ composer tests

# 运行某一具体测试用例
$ composer tests/JPush/xxTest.php

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/jpush/jpush-api-php-client.

License

The library is available as open source under the terms of the MIT License.

More Repositories

1

aurora-imui

General IM UI components. Android/iOS/RectNative ready. 通用 IM 聊天 UI 组件,已经同时支持 Android/iOS/RN。
Java
5,701
star
2

jpush-react-native

JPush's officially supported React Native plugin (Android & iOS). 极光推送官方支持的 React Native 插件(Android & iOS)。
Objective-C
1,336
star
3

jpush-phonegap-plugin

JPush's officially supported PhoneGap/Cordova plugin (Android & iOS). 极光推送官方支持的 PhoneGap/Cordova 插件(Android & iOS)。
JavaScript
924
star
4

jpush-flutter-plugin

JPush's officially supported Flutter plugin (Android & iOS). 极光推送官方支持的 Flutter 插件(Android & iOS)。
Objective-C
825
star
5

jpush-api-java-client

JiGuang's officially supported Java client library for accessing JPush APIs. 极光官方支持的 Java 版本服务器端 SDK。
Java
724
star
6

jchat-android

JChat android app. A real app based on JMessage SDK.
Java
378
star
7

jchat-swift

Swift version of JChat iOS.
Swift
288
star
8

jpush-api-nodejs-client

JPush's officially supported Node.js client library for accessing JPush APIs. 极光推送官方支持的 Node.js 版本服务器端 SDK。
JavaScript
240
star
9

jpush-api-python-client

JPush's officially supported Python client library for accessing JPush APIs. 极光推送官方支持的 Python 版本服务器端 SDK。
Python
208
star
10

jmessage-react-plugin

Objective-C
184
star
11

jmessage-flutter-plugin

JMessage's Flutter plugin (Android & iOS). 极光推送官方支持的 Flutter 插件(Android & iOS)。
Java
166
star
12

jpush-hbuilder-demo

极光推送官方提供的 HBuilder 示例代码,可用于快速集成 JPush SDK 到 HBuilder 项目里。
JavaScript
144
star
13

jpush-api-csharp-client

JPush's officially supported C# client library for accessing JPush APIs. 极光推送官方支持的 C# 版本服务器端 SDK。
C#
135
star
14

jpush-unity3d-plugin

JPush's officially supported Unity3d plugin (Android & iOS). 极光推送官方支持的 Unity3d 插件(Android & iOS)。
C#
114
star
15

jpush-docs

JPush docs on official website. 极光推送官方文档。
HTML
114
star
16

jverify-flutter-plugin

JPush's officially supported Flutter plugin (Android & iOS). 极光推送官方支持的 Flutter 插件(Android & iOS)。
Objective-C
112
star
17

jmessage-phonegap-plugin

JiGuang's officially supported JMessage PhoneGap/Cordova plugin (Android & iOS). 极光官方支持的 IM PhoneGap/Cordova 插件。
JavaScript
108
star
18

jchat-web

JChat web
TypeScript
105
star
19

jshare-react-native

Objective-C
104
star
20

jchat-ios

JChat iOS app, a real app based on JMessage SDK.
Objective-C
102
star
21

jpush-api-ruby-client

JPush's officially supported Ruby client library for accessing JPush APIs. 极光推送官方支持的 Ruby 版本服务器端 SDK。
Ruby
99
star
22

jbox

极光宝盒,一个基于 JPush 的轻便易用的通知框架。
Python
73
star
23

aurora-imui-examples

Swift
65
star
24

jmessage-api-java-client

JiGuang's officially supported Java client library for accessing JMessage APIs. 极光官方支持的 Java 版本服务器端 SDK。
Java
60
star
25

jpush-swift-demo

Offically supported Swift Demo for JPush iOS SDK.
Swift
55
star
26

janalytics-react-native

Objective-C
52
star
27

jcore-react-native

Objective-C
49
star
28

jpush-hbuilder-plugin

Vue
48
star
29

jmessage-api-php-client

JMessage's officially supported PHP client library for accessing JMessage APIs. 极光IM官方支持的 PHP 版本服务器端 SDK。
PHP
43
star
30

janalytics-flutter-plugin

Dart
39
star
31

jmessage-android-uikit

极光IM Android SDK UI 组件
Java
39
star
32

jmessage-ios-uikit

极光IM iOS SDK UI 组件
Objective-C
31
star
33

jpush-java-library

Java library for JPush API. Moved to - https://github.com/jpush/jpush-api-java-client 本库不再维护,做了迁移。
Java
30
star
34

jpush-ios-sdk-pod

JPush's officially supported iOS SDK Pod for CocosPods. 极光推送官方支持的 iOS SDK Pod.
Objective-C
28
star
35

jverification-react-native

Objective-C
28
star
36

jsms-api-java-client

JiGuang's officially supported Java client library for accessing JSMS APIs. 极光官方支持的 JSMS Java 版本服务器端 SDK。
Java
27
star
37

jverification-hbuilder-plugin

极光认证官方支持的 hbuilder 插件(Android & iOS)
Objective-C
24
star
38

jshare-flutter-plugin

JShare's officially supported Flutter plugin (Android & iOS). 极光分享官方支持的 Flutter 插件(Android & iOS)。
Dart
24
star
39

cordova-plugin-jcore

Java
20
star
40

jiguang-java-client-common

Common lib for JiGuang Java clients.
Java
18
star
41

jpush-cocos2d-x-plugin

JPush's officially supported Cocos2d-x plugin (Android & iOS). 极光推送官方支持的 Cocos2d-x 插件(Android & iOS)。
Python
18
star
42

jmlink-flutter-plugin

JPush's officially supported Flutter plugin (Android & iOS). 极光推送官方支持的 Flutter 插件(Android & iOS)。
Dart
18
star
43

jpush-android-samples

JPush's officially supported Android SDK samples for demo SDK APIs. 极光推送官方支持的 Android SDK 示例,以演示如何使用 SDK APIs。
Java
18
star
44

cordova-plugin-janalytics

Objective-C
14
star
45

JVerfication-Demo

Objective-C
14
star
46

android-push-example

更丰富地演示基于 JPush Android SDK 可以实现的功能、效果。
Java
14
star
47

jchat-windows

JChat Windows Application
C++
13
star
48

jmessage-api-csharp-client

JMessage's officially supported CSharp client library for accessing JMessage APIs. 极光IM官方支持的 CSharp 版本服务器端 SDK。
C#
13
star
49

jmrtc-react-native

Objective-C
10
star
50

jmessage-api-python-client

JiGuang's officially supported Python client library for accessing JMessage APIs. 极光官方支持的 JMessage Python 版本服务器端 SDK。
Python
9
star
51

jpush-weex-plugin

Java
8
star
52

jsms-api-php-client

JiGuang's officially supported PHP client library for accessing JSMS APIs. 极光官方支持的 JSMS PHP 版本服务器端 SDK。
PHP
8
star
53

cordova-plugin-jsms

JiGuang's officially supported JSMS PhoneGap/Cordova plugin (Android & iOS). 极光官方支持的短信验证码 PhoneGap/Cordova 插件。
Objective-C
8
star
54

JIoT-SDK-C

C
7
star
55

jmlink_demo

jmlink demo
Java
7
star
56

jpush-api-go-client

JPush's officially supported Go-lang client library for accessing JPush APIs. 极光推送官方支持的 Go 语言版本服务器端 SDK。
5
star
57

jpush-opensource

JPush official website for open-source projects.
CSS
5
star
58

JVerification-cordova-plugin

极光认证官方支持的 cordova 插件(Android & iOS)
Objective-C
4
star
59

jmrtc-phonegap-plugin

Objective-C
4
star
60

cordova-plugin-jshare

极光官方支持的社交分享 Cordova 插件。
3
star
61

jsms-react-native

Java
3
star
62

jmessage-ios-pod

JMessage iOS SDK (framework) for CocoaPods
Objective-C
3
star
63

jpush-ios-samples

JPush's officially supported iOS SDK samples for demo SDK APIs. 极光推送官方支持的 iOS SDK 示例,以演示如何使用 SDK APIs。
Objective-C
3
star
64

jsms-api-csharp-client

JiGuang's officially supported C# client library for accessing JSMS APIs. 极光官方支持的 JSMS C# 版本服务器端 SDK。
C#
3
star
65

ios-resources-review

2
star
66

jmlink-react-native

JMlink's officially supported react native plugin (Android & iOS). 极光魔链官方支持的 react native 插件(Android & iOS)。
Objective-C
2
star
67

JIoT-rtthread-package

JIoT SDK rt-thread package
C
2
star
68

jmessage-android-samples

极光IM Android SDK 样例
2
star
69

joperate-flutter-plugin

Dart
2
star
70

JIoT-SDK-Android

极光 IoT 客户端 SDK Android
Java
1
star
71

jmessage-unity3d-plugin

1
star
72

jcore-hbuilder-plugin

Objective-C
1
star
73

janalytics-hbuilder-demo

HTML
1
star
74

jsms-api-python-client

Python
1
star
75

Jpush-Google

1
star