Receive unread messages on a particular pubnub php sdk channel

Purpose: - receiving unread messages on a specific channel.

User login to the upitch website.

As soon as he goes to the message page, we support message_page_visited_count = 1

when the user moves from the message page to any other page that we update message_page_visited_count = 0and update the timestamp.

now for updating timestamp we use the mysql function strtotime("now")something like this.

$this->Userlink->updateAll(
                    array('pubnub_time_stamp' => strtotime("now")), array('Userlink.id' => $loggedInUser)
            ); // updating timestamp for logged in user 1455687812

Which updates the 1455687812ten-digit timestamp in our database for a registered user.

As discussed with the pubnub team, the pubnub team stated to add 7 zeros to the right end of my timestamp. Which turns into14556878120000000

I have built-in php-sdk pubnub

include_once './vendor/autoload.php';
use Pubnub\Pubnub;
$publish_key   = publish_key
$subscribe_key = subscribe_key
$pubnub = new Pubnub($publish_key, $subscribe_key);

.

history(
string $channel, 
integer $count = 100, 
boolean $include_token = null,
integer $start = null, 
integer $end = null,
boolean $reverse = false)

: -

$result= $pubnub->history(
"2242_2272_1116", //my channel
null,
true, 
null,
14556878120000000, //endtime token with 7 zeros
null);
echo "<pre>";
print_r($result);die;

, ? -

7 pubnub, (1455687812) (17 ).

, , , ?

.

- .   //TIMETOKENS AND MESSAGES

14556879844588614  Really want some more levels
14556879769565496  The fact I can see
14556871094404310  Haunted
14556871091411782  Hello
14556870983775230  Hello

$result= $pubnub->history(
"2242_2272_1116", 
null,
true, 
null,
14556871094404310, null);
echo "<pre>";
print_r($result);die;

3- , 14556871094404310, Haunted. ,

14556879844588614  Really want some more levels
14556879769565496  The fact I can see

2- ?

: - timetoken pubnub.

this, !

.

+4

Source: https://habr.com/ru/post/1629129/


All Articles