極光推送 PHP sdk

來源:互聯網
上載者:User

標籤:

<?phpdefined(‘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 JPush\Client 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 (\JPush\Exceptions\APIConnectionException $e) {            // try something here            print $e;        } catch (\JPush\Exceptions\APIRequestException $e) {            // try something here            print $e;        }        print_r($response);    }}

 

極光推送 PHP sdk

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.