Why not adopt me?
NAME
Google::Fusion - Interface to the Google Fusion Tables API
VERSION
Version 0.10
SYNOPSIS
my $fusion = Google::Fusion->new(
client_id => $client_id,
client_secret => $client_secret,
token_store => $token_store,
);
# Get the result for a query
my $result = $fusion->query( $sql );
# Print out the rows returned
foreach( @{ $result->rows } ){
print join( ',', @{ $_ } ) . "\n";
}
PARAMS/ACCESSORS
One of the following combination of parameters is required:
client_id and client_secret
You will be prompted with a URL, with which you will atain an access_code.
client_id, client_secret, access_code
The OAuth2 client will complete the authorization process for you and get the refresh_token and access_token for you
refresh_token and optionally access_token
The OAuth2 client will get a valid access_token for you if necessary, and refresh it when necessary.
access_token
You will be able to make requests as long as the access_token is valid.
client_id <Str>
The client id of your application.
client_secret <Str>
The secret for your application
refresh_token <Str>
Refresh token. Can be defined here, otherwise it will be aquired during the authorization process
access_token <Str>
A temporary access token aquired during the authorization process Can be defined here, otherwise it will be aquired during the authorization process
keep_alive <Int>
Use keep_alive for connections - this will make the application /much/ more responsive.
Default: 1
headers <Bool>
Responses passed with headers.
Default: 1
access_code <Str>
The code returned during the OAuth2 authorization process with which access_token and refresh_token are aquired.
auth_client
A Net::OAuth2::Moosey::Client object with which authenticated requests are made. If you are running in application mode (interactive), then you can accept the default. If you already have an authenticated client, then initialise with it. If you have some required parameters (access_token, refresh_token or access_code), but no client object yet, then just define these parameters, and allow the client to be created for you.
query_cache <Str>
Path to a directory to use as a query cache. This can be used to cache your results for blazing fast performance, and not actually hitting google for every query when testing, but should not be enabled in a productive environment otherwise you will have stale content.
token_store <Str>
Path to the token store file to store access/refresh tokens
METHODS
query
Submit a (Googley) SQL query. Single argument is the SQL. Return is a Google::Fusion::Result object
Example:
my $result = $fusion->query( 'SELECT * FROM 123456' );
get_fresh_access_token
Force the OAuth access token to be refreshed
Example:
$fusion->get_fresh_access_token();
add_to_insert_buffer
The Fusion Table intefrace allows multiple INSERT commands to be sent in one query. This can be used similarly to the query method, but and will reduce the number of queries you use.
# Get data from your local database $sth->execute(); while( my $row = $sth->fetchrow_hashref ){ $fusion->add_to_insert_buffer( sprintf( "INSERT INTO INTO 12345 ( Id, Text ) VALUES( '%s', '%s' )", $row->{Id}, $row->{Text} ) ); } $fusion->send_insert_buffer;
Obviously this can be further optimised by having many VALUES per INSERT.
If a send_insert_buffer was triggered during the add, this is returned, otherwise undef is returned
send_insert_buffer
Flush the rest of the insert buffer
AUTHOR
Robin Clarke, <perl at robinclarke.net>
BUGS
Please report any bugs or feature requests to bug-google-fusion at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Google-Fusion. 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 Google::Fusion
You can also look for information at:
Repository on Github
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
Copyright 2011 Robin Clarke.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.