The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WWW::Freebox - Access to FreeboxOS API

VERSION

Version 0.01

SYNOPSIS

Before using this module in your script(s) you need to acquire a token and a ID.

    use WWW::Freebox;
    
    my $fbx = WWW::Freebox->new("mafreebox.freebox.fr");
    
    my $app_id = "perl.helloworld";
    my $app_name = "Perl script";
    my $app_version = "1.0";
    my $device_name = "John's computer";
    
    # You have to launch this method only once because a unique token and a unique ID are required per application.
    my ($app_token, $track_id) = $fbx->authorize($app_id, $app_name, $app_version, $device_name);
    # You need to store $app_token and $track_id (in a config file for example)
    # You will have to grant access to your application (a message will be displayed on LCD screen of the Freebox Server)

Once you've got the token and the ID you will be able to use the module as follow :

    use WWW::Freebox;
    
    my $fbx = WWW::Freebox->new("mafreebox.freebox.fr");
    
    $fbx->login("perl.helloworld", $app_token, $track_id);
    
    if($fbx->{permissions}{downloader}){
        # Doing a request to FreeboxOS API
        my $content = [download_dir => 'path', download_file => ['file.torrent']];
        my $jsonResponse = $fbx->request("downloads/add", 1, $content);
    }
    

You can find more informations at http://dev.freebox.fr/sdk/os/.

METHODS

new(freebox)

    my $fbx = WWW::Freebox->new("mafreebox.freebox.fr");
    

$fbx->authorize(app_id, app_name, app_version, device_name)

    my ($app_token, $track_id) = $fbx->authorize("perl.helloworld", "Perl script", "1.0", "John's computer");
    

$fbx->login($app_id, $app_token, $track_id)

    $fbx->login("perl.helloworld", $app_token, $track_id);
    

$fbx->request($url, $method [, $content/@content])

    # Possible values for the second parameter (method):
    # 0: GET
    # 1: POST
    # 2: PUT
    # 3: DELETE
    
    my $jsonResponse = $fbx->request("downloads/", 0);
    
    my $content = '{"io_priority": "high","status": "stopped"}';
    my $jsonResponse = $fbx->request("downloads/16", 2, $content);
    
    my @content = [download_dir => 'path', download_file => ['file.torrent']];
    my $jsonResponse = $fbx->request("downloads/add", 1, @content);
    

$fbx->logout()

    $fbx->logout();
    

$fbx->close()

    $fbx->close();
    

AUTHOR

Alexandre van Beurden, <alexandre.vanbeurden.dev(at)gmail.com>

BUGS

Please report any bugs or feature requests to bug-www-freebox at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Freebox. You can also open an issue at https://github.com/KiLlOrBe/PM-Freebox.

SUPPORT

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

    perldoc WWW::Freebox

You can also look for information at:

If you need help or you have any question about this module feel free to email me.

LICENSE AND COPYRIGHT

Copyright 2015 Alexandre van Beurden.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.