Maxim Nikolenko > OpenTok-API > OpenTok::API

Download:
OpenTok-API-0.03.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.03   Source  

NAME ^

OpenTok::API - Perl SDK for OpenTok http://www.tokbox.com/

VERSION ^

Version 0.03

SYNOPSIS ^

1. Generate Token

    use OpenTok::API;
    
    # Get your own API-keys from http://www.tokbox.com/opentok
    my $ot = OpenTok::API->new(
        'api_key'    => $api_key, 
        'api_secret' => $api_secret,
        'mode'       => "development"|"production",
    );

2. Create new session

    my $session_id = $ot->create_session( 
        location => '', 
        'p2p.preference' => "enabled"|"disabled" 
    )->getSessionId();

3. Generate a new token for session

    my $token = $ot->generate_token(
        session_id => $session_id, 
        role => "publisher"|"subscriber"|"moderator" 
    );

4. Now insert your $api_key, $session_id, and $token into your template using your favourite templating engine

    # TT example 

    # In server side code
    my $tt = Template->new(...});
    my $vars = { api_key => $api_key, session_id => $session_id, token => $token };
    $tt->process($template, $vars) || die $tt->error(), "\n";

    # In HTML (javascript part)
    var apiKey    = "[% api_key %]";
    var sessionId = "[% session_id %]";
    var token     = "[% token %]";
    ...
    var session = TB.initSession(sessionId);
    session.addEventListener("sessionConnected", sessionConnectedHandler);
    session.addEventListener("streamCreated", streamCreatedHandler);
    session.connect(apiKey,token);

SUBROUTINES/METHODS ^

new

Creates and returns a new OpenTok::API object

    my $ot = OpenTok::API->new(
        'api_key'    => $api_key, 
        'api_secret' => $api_secret,
        'mode'       => "development"|"production",
    );

generate_token

Generates a token for specific session.

    my $token = $ot->generate_token(
        session_id => $session_id, 
        role => "publisher"|"subscriber"|"moderator",
        expire_time => (time()+24*3600),
    );

create_session

Creates and returns OpenTok::API::Session object

    my $session_id = $ot->create_session( 
        location => '', 
        'p2p.preference' => "enabled"|"disabled" 
    )->getSessionId();

AUTHOR ^

This version: Dr James Freeman, <james at gp2u.com.au> Original version: Maxim Nikolenko, <root at zbsd.ru>

BUGS ^

Please report any bugs or feature requests to bug-opentok-api at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=OpenTok::API. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT ^

You can find documentation for this module with the perldoc command.

    perldoc OpenTok::API

You can also look for information at:

http://www.tokbox.com/opentok

LICENSE AND COPYRIGHT ^

Copyright 2011 Maxim Nikolenko.

This module is released under the following license: BSD

syntax highlighting: