search
Homephp教程php手册改写百度云推送SDK,PHP PEAR 包:Services_Baidu_Push

改写百度云推送SDK,PHP PEAR 包:Services_Baidu_Push

Jun 13, 2016 am 11:31 AM
iphonepearphppushsdkservicesclouduseBagPushrewriteBaidu

iPhone使用apple push很方便,而Android很多厂商删除了google push,而且google在大陆连不上,所以要用别的办法。

Android常见的推送服务商有:极光推送(https://www.jpush.cn/)、百度云推送。

app加入推送的lib,会有一个常驻后台进程,通过推送服务商推送消息,无需启动app。

 

百度云推送官方文档:http://developer.baidu.com/cloud/push

标准URI

PEAR的优势:一键安装到php/lib/php目录,require即可使用,很方便。

百度推送的官方sdk不符合PEAR标准,使用不便,不想为百度重写,所以我改写了一下(sdk中带的很多垃圾没去改写),安装步骤如下:

pear channel-discover sinkcup.github.io/<span pear
pear </span><span install</span> sinkcup/Services_Baidu_Push

使用步骤:

1、注册登录百度开发者后台,获得api key和secret key,在app里添加lib。

2、demo(参考https://github.com/sinkcup/Services_Baidu_Push/blob/master/tests/Services/Baidu/PushTest.php)

<?<span php
</span><span require_once</span> 'Services/Baidu/Push.php'<span ;

</span><span $apiKey</span> = 'asdf'<span ;
</span><span $secretKey</span> = 'qwer'<span ;
</span><span $c</span> = <span new</span> Services_Baidu_Push(<span $apiKey</span>, <span $secretKey</span><span );
</span><span $msg</span> = <span array</span><span (
    </span>"description"=> "testSimplePushToAndroid群发",
    "notification_basic_style"=>7,<span 
);
</span><span $r</span> = <span $c</span>->simplePushToAndroid(<span $msg</span><span );
</span><span var_dump</span>(<span $r</span><span );
</span><span exit</span><span ;
</span>?>

<span bool</span>(<span true</span>)

我的PEAR 频道:http://sinkcup.github.io/pear/

项目源代码:https://github.com/sinkcup/Services_Baidu_Push

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.