Firefox::Sync::Client - A Client for the Firefox Sync Server
Simple example:
use Firefox::Sync::Client; my $c = new Firefox::Sync::Client( URL => 'https://your.ffsync-server.org/', User => 'your@mail.address', Password => 'SyncPassword', SyncKey => 'x-thisx-isxxx-thexx-secre-txkey', ); my $tabs = $c->get_tabs; foreach my $client (@$tabs) { print $client->{'payload'}->{'clientName'} . "\n"; foreach my $tab (@{$client->{'payload'}->{'tabs'}}) { print ' ' . $tab->{'title'} . "\n"; print ' --> ' . $tab->{'urlHistory'}[0] . "\n"; } print "\n"; }
Advanced example, printing HTML code with all bookmarks and links. Results will be cached:
use Firefox::Sync::Client; use utf8; binmode STDOUT, ':encoding(UTF-8)'; my $c = new Firefox::Sync::Client( URL => 'https://your.ffsync-server.org/', User => 'your@mail.address', Password => 'SyncPassword', SyncKey => 'x-thisx-isxxx-thexx-secre-txkey', CacheFile => '/tmp/ffsync-cache', ); my $bm = $c->get_bookmarks; print '<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body>' . "\n"; print_children(1, $bm); print '</body></html>' . "\n"; sub print_children { my ($h, $bm) = @_; foreach my $item (@$bm) { if ($item->{'payload'}->{'type'} eq 'folder') { print '<h' . $h . '>' . $item->{'payload'}->{'title'} . '</h' . $h . '>' . "\n"; print '<ul>' . "\n"; print_children($h + 1, $item->{'payload'}->{'children'}); print '</ul>' . "\n"; } if (defined $item->{'payload'}->{'bmkUri'}) { print '<li>'; print '<a href="' . $item->{'payload'}->{'bmkUri'} . '" target="_blank">' . $item->{'payload'}->{'title'} . '</a>'; print '</li>' . "\n"; } else { print '<hr>' . "\n"; } } }
This module implements a client to the popular Firefox Sync service.
More information on the server can be found at Mozilla: https://developer.mozilla.org/en-US/docs/Firefox_Sync
For now, this module is only a read-only client. That means, it is possible to get some collections of things from the server by using either the specialized get_* methods or get_raw_collection(). The methods usually return an array reference.
In a future release, caching and some other improvements will be realized.
What each method actually returns, can be different. But it will always be a reference to an array containing hashes. Every hash has the following keys:
id - The ID of the element. modified - A timestamp of the last modification payload - Contains a hash of elements. The keys are different for each collection
Constructor. You can set the following parameters during construction:
ProtocolVersion - defaults to 1.1 URL - The server address User - The username or e-mail address Password - The password SyncKey - The sync/recovery key CacheFile - A file to be used for caching CacheLifetime - Lifetime of cached requests in seconds
Returns an array reference containing all elements of the given collection.
The following collections are tested (but other collections may also work):
bookmarks prefs clients forms history passwords tabs addons
You can not fetch the metadata with this method, please use get_meta() instead. Also, if you plan to do something with the 'bookmarks' collection, better use get_bookmarks(), as it returns a somewhat nicer formatted array reference.
Returns an array of the synced add-on data.
Returns all bookmark collections, folders and bookmarks in a well formatted array. That means, the references are recursively resolved in the tree.
Returns all known data of the connected Sync clients.
Returns an array of synchronized form input data.
Returns the synced browser history.
Returns an array containing the sync metadata for the user.
Returns all synchronized passwords. The passwords are returned unencrypted.
Returns the synchronized browser preferences.
Returns an array of tabs opened on each Sync client / Browser.
Robin Schroeder, <schrorg@cpan.org>
Copyright (C) 2012 by Robin Schroeder
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10 or, at your option, any later version of Perl 5 you may have available.
To install Firefox::Sync::Client, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Firefox::Sync::Client
CPAN shell
perl -MCPAN -e shell install Firefox::Sync::Client
For more information on module installation, please visit the detailed CPAN module installation guide.