Home  >  Article  >  Backend Development  >  Rewrite Baidu Cloud Push SDK, PHP PEAR package: Services_Baidu_Push_PHP Tutorial

Rewrite Baidu Cloud Push SDK, PHP PEAR package: Services_Baidu_Push_PHP Tutorial

WBOY
WBOYOriginal
2016-07-20 11:16:14916browse

It is very convenient to use apple push on iPhone, but many Android manufacturers have deleted google push, and google cannot be connected in mainland China, so we have to use other methods.

Common Android push service providers include: Jiguang Push (https://www.jpush.cn/) and Baidu Cloud Push.

When the app adds the push lib, there will be a resident background process to push messages through the push service provider without starting the app.

Baidu cloud push official documentation: http://developer.baidu.com/cloud/push

Standard URI

Advantages of PEAR: One-click installation to the php/lib/php directory, require to use, very convenient.

The official sdk pushed by Baidu does not meet the PEAR standard and is inconvenient to use. I didn’t want to rewrite it for Baidu, so I rewritten it (a lot of garbage in the sdk was not rewritten). The installation steps are as follows:

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

Usage steps:

1. Register and log in to Baidu Developer Backend, obtain the API key and secret key, and add lib to the app.

2. demo (refer to 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>)

My PEAR channel: http://sinkcup.github.io/pear/

Project source code: https://github.com/sinkcup/Services_Baidu_Push

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/440120.htmlTechArticleIt is very convenient to use apple push on iPhone, but many Android manufacturers have deleted google push, and google cannot be connected in mainland China. So use other methods. Common Android push service providers are: Aurora...
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