GithubHelp home page GithubHelp logo

php's Introduction

###YOU MUST HAVE A PUBNUB ACCOUNT TO USE THE API. ###http://www.pubnub.com/account

PubNub 3.4 Real-time Cloud Push API - PHP

www.pubnub.com - PubNub Real-time Push Service in the Cloud. http://www.pubnub.com/blog/php-push-api-walkthrough/

PubNub is a Massively Scalable Real-time Service for Web and Mobile Games. This is a cloud-based service for broadcasting Real-time messages to thousands of web and mobile clients simultaneously.

PHP Push API

$pubnub = new Pubnub(
    "demo",  ## PUBLISH_KEY
    "demo",  ## SUBSCRIBE_KEY
    "",      ## SECRET_KEY
    false    ## SSL_ON?
);

Send Message (PUBLISH)

$info = $pubnub->publish(array(
    'channel' => 'hello_world', ## REQUIRED Channel to Send
    'message' => 'Hey World!'   ## REQUIRED Message String/Array
));
print_r($info);

Request Server Time (TIME)

$timestamp = $pubnub->time();
var_dump($timestamp);            ## Prints integer timestamp.

Receive Message (SUBSCRIBE) PHP 5.2.0

$pubnub->subscribe(array(
    'channel'  => 'hello_world',        ## REQUIRED Channel to Listen
    'callback' => create_function(      ## REQUIRED PHP 5.2.0 Method
        '$message',
        'var_dump($message); return true;'
    )
));

Receive Message (SUBSCRIBE) PHP 5.3.0

$pubnub->subscribe(array(
    'channel'  => 'hello_world',        ## REQUIRED Channel to Listen
    'callback' => function($message) {  ## REQUIRED Callback With Response
        var_dump($message);  ## Print Message
        return true;         ## Keep listening (return false to stop)
    }
));

Realtime Join/Leave Events (Presence)

$pubnub->presence(array(
    'channel'  => $channel,
    'callback' => function($message) {
        print_r($message);
		echo "\r\n";
        return true;
    }
));

On-demand Occupancy Status (here_now)

$here_now = $pubnub->here_now(array(
    'channel' => $channel
));

Detailed History (detailedHistory())

$history = $pubnub->detailedHistory(array(
    'channel' => $channel,
    'count'   => 10,
    'end'   => "13466530169226760"
));

php's People

Contributors

cgrice avatar cvconover avatar stephenlb avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.