Пример #1
0
 /**
  * @depends testConfig
  * @param string $channelId
  */
 function testSendMessage()
 {
     $channelId = null;
     $channelId = class_exists('BAIDU_PUSH_CONFIG') ? BAIDU_PUSH_CONFIG::test_channel_id : false;
     if (empty($channelId)) {
         echo "BAIDU_PUSH_CONFIG::test_channel_id not exisist, ignore the testSendMessage! \n";
         return;
     }
     // creaete SDK instance at default. and there is will be use the default_apik and default_secretkey.
     $sdk = new PushSDK();
     // message content.
     $message = array('title' => 'Hi!.', 'description' => "hello!, this message from baidu push service.");
     // option, set the msg_type is notice;
     $opts = array('msg_type' => 1);
     //send out;
     $rs = $sdk->pushMsgToSingleDevice($channelId, $message, $opts);
     // check the return;
     $this->assertNotFalse($rs, $sdk->getLastErrorMsg());
     $this->assertNotNull($sdk->getRequestId(), 'missing request_id');
     $this->assertTrue(array_key_exists('msg_id', $rs), 'missing msg_id');
     echo "finish the test and every thing is good!\n";
 }