SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Downloaden Sie, um offline zu lesen
Google API
Perl
Client
Granada Perl Workshop 2014
Who are you?
Alberto Jesús
Gutiérrez Juanes
GDG Granada GDG Spain
@aljesus_gj
Granada Perl Workshop 2014
Where?
Repository GitHub
http://github.com/comewalk/google-api-perl-
client
Granada Perl Workshop 2014
HELP
Granada Perl Workshop 2014
VERSIÓN
0.13
07/2011
Contribute to the project
Granada Perl Workshop 2014
Perl?
google-api-
dotnet
go
java
objectivec
php
python
ruby
-client
Granada Perl Workshop 2014
What?
AdSense Management API
Analytics
Blogger
Calendar
Plus
URL Shortener
WebFonts
Granada Perl Workshop 2014
How?
Granada Perl Workshop 2014
Why?
OAuth provides client applications a 'secure
delegated access' to server resources on behalf of a
resource owner.
It specifies a process for resource owners to
authorize third-party access to their server resources
without sharing their credentials.
Granada Perl Workshop 2014
● Lista Calendarios
● Lista Eventos
● Crear un evento
● Obtener un evento
● Actualizar un evento
● Eliminar un evento
● Mover un evento
● Obtener instancias
● ...
Granada Perl Workshop 2014
use Google::API::Client;
use Google::API::OAuth2::Client;
use lib 'eg/lib';
use Sample::Utils qw/get_or_restore_token store_token/;
use constant MAX_PAGE_SIZE => 50;
my $client = Google::API::Client->new;
my $service = $client->build('calendar', 'v3');
my $file = "$FindBin::Bin/../client_secrets.json";
my $auth_driver = Google::API::OAuth2::Client->new_from_client_secrets($file, $service->{auth_doc});
my $dat_file = "$FindBin::Bin/token.dat";
my $access_token = get_or_restore_token($dat_file, $auth_driver);
Granada Perl Workshop 2014
# Call calendarlist.list
my $res = $service->calendarList->list(
body => {
maxResults => MAX_PAGE_SIZE,
minAccessRole => 'owner',
}
)->execute({ auth_driver => $auth_driver });
my $calendar_id = $res->{items}->[0]->{id};
my $dest_calendar_id = $res->{items}->[1]->{id};
Granada Perl Workshop 2014
# Call events.list
my $page_token;
my $count = 1;
do {
say "=== page $count ===";
my %body = (
calendarId => $calendar_id,
);
if ($page_token) {
$body{pageToken} = $page_token;
}
$res = $service->events->list(
body => %body,
)->execute({ auth_driver => $auth_driver });
$page_token = $res->{nextPageToken};
for my $event (@{$res->{items}}) {
say encode_utf8($event->{summary});
}
$count++;
} until (!$page_token);
Granada Perl Workshop 2014
# Create a new event
say '=== Create a new event ===';
my $new_event = {
'summary' => 'Appointment',
'location' => 'Somewhere',
'start' => {
'dateTime' => '2012-08-03T10:00:00+09:00',
},
'end' => {
'dateTime' => '2012-08-03T10:25:00+09:00',
},
};
my $added_event = $service->events->insert(
calendarId => $calendar_id,
body => $new_event,
)->execute({ auth_driver => $auth_driver });
say $added_event->{id};
Granada Perl Workshop 2014
# Get an event
say '=== Get a event ===';
my $got_event = $service->events->get(
body => {
calendarId => $calendar_id,
eventId => $added_event->{id},
}
)->execute({ auth_driver => $auth_driver });
say $got_event->{id};
# Update an event
say '=== Update an event ===';
$got_event->{summary} = 'Appointment at Somewhere';
my $updated_event = $service->events->update(
calendarId => $calendar_id,
eventId => $got_event->{id},
body => $got_event,
)->execute({ auth_driver => $auth_driver });
say $updated_event->{updated};
# Delete an event
say '=== Delete an event ===';
my $deleted_event = $service->events->delete(
calendarId => $calendar_id,
eventId => $got_event->{id},
)->execute({ auth_driver => $auth_driver });
Granada Perl Workshop 2014
use Google::API::Client;
use OAuth2::Client;
my $client = Google::API::Client->new;
my $service = $client->build('plus', 'v1');
my $auth_driver = OAuth2::Client->new({
auth_uri => Google::API::Client->AUTH_URI,
token_uri => Google::API::Client->TOKEN_URI,
client_id => '<YOUR CLIENT ID>',
client_secret => '<YOUR CLIENT SECRET>',
redirect_uri => 'urn:ietf:wg:oauth:2.0:oob',
auth_doc => $service->{auth_doc},
});
# people.get
my $res = $service->people->get(
body => {
userId => 'me‘
})->execute({ auth_driver => $auth_driver });
Granada Perl Workshop 2014
#!/usr/bin/perl
use strict;
use warnings;
use feature qw/say/;
use Data::Dumper;
use URI;
use Google::API::Client;
my $service = Google::API::Client->new->build('urlshortener', 'v1');
my $url = $service->url;
# Create a shortened URL by inserting the URL into the url collection.
my $body = {
'longUrl' => 'http://code.google.com/apis/urlshortener/',
};
my $res = $url->insert(body => $body)->execute;
say Dumper($res);
my $short_url = $res->{'id'};
# Convert the shortened URL back into a long URL
$res = $url->get(body => { shortUrl => $short_url })->execute;
say Dumper($res);
__END__
Granada Perl Workshop 2014
#!/usr/bin/perl
use strict;
use warnings;
use feature qw/say/;
use Data::Dumper;
use URI;
use Google::API::Client;
use Google::API::OAuth2::Client;
use lib 'eg/lib';
use Sample::Utils qw/get_or_restore_token store_token/;
my $service = Google::API::Client->new->build('urlshortener', 'v1');
my $file = "$FindBin::Bin/../client_secrets.json";
my $auth_driver = Google::API::OAuth2::Client->new_from_client_secrets($file, $service->{auth_doc});
my $dat_file = "$FindBin::Bin/token.dat";
my $access_token = get_or_restore_token($dat_file, $auth_driver);
my $url = $service->url;
# Create a shortened URL by inserting the URL into the url collection.
my $body = {
'longUrl' => 'http://code.google.com/apis/urlshortener/',
};
my $res = $url->insert(body => $body)->execute;
my $res = $url->insert(body => $body)->execute({ auth_driver => $auth_driver });
say Dumper($res);
__END__
W
ITH
OAuth2
What’s next?
Getting Started with Google APIs Client
code.google.com/p/google-api-perl-client/
What’s next?
Getting Started with Google APIs Client
code.google.com/p/google-api-perl-client/

Weitere ähnliche Inhalte

Was ist angesagt?

Azure Durable Functions (2019-04-27)
Azure Durable Functions (2019-04-27)Azure Durable Functions (2019-04-27)
Azure Durable Functions (2019-04-27)Paco de la Cruz
 
Azure Durable Functions (2019-03-30)
Azure Durable Functions (2019-03-30) Azure Durable Functions (2019-03-30)
Azure Durable Functions (2019-03-30) Paco de la Cruz
 
Azure Key Vault Integration in Scala
Azure Key Vault Integration in ScalaAzure Key Vault Integration in Scala
Azure Key Vault Integration in ScalaBraja Krishna Das
 
E.D.D.I - Open Source Chatbot Platform
E.D.D.I - Open Source Chatbot PlatformE.D.D.I - Open Source Chatbot Platform
E.D.D.I - Open Source Chatbot PlatformGregor Jarisch
 
Appengine Java Night #2b
Appengine Java Night #2bAppengine Java Night #2b
Appengine Java Night #2bShinichi Ogawa
 
Appengine Java Night #2a
Appengine Java Night #2aAppengine Java Night #2a
Appengine Java Night #2aShinichi Ogawa
 
OSMC 2014: MonitoringLove with Sensu | Jochen Lillich
OSMC 2014: MonitoringLove with Sensu | Jochen LillichOSMC 2014: MonitoringLove with Sensu | Jochen Lillich
OSMC 2014: MonitoringLove with Sensu | Jochen LillichNETWAYS
 
Serverless APIs, the Good, the Bad and the Ugly (2019-09-19)
Serverless APIs, the Good, the Bad and the Ugly (2019-09-19)Serverless APIs, the Good, the Bad and the Ugly (2019-09-19)
Serverless APIs, the Good, the Bad and the Ugly (2019-09-19)Paco de la Cruz
 

Was ist angesagt? (9)

Azure Durable Functions (2019-04-27)
Azure Durable Functions (2019-04-27)Azure Durable Functions (2019-04-27)
Azure Durable Functions (2019-04-27)
 
Azure Durable Functions (2019-03-30)
Azure Durable Functions (2019-03-30) Azure Durable Functions (2019-03-30)
Azure Durable Functions (2019-03-30)
 
Azure Key Vault Integration in Scala
Azure Key Vault Integration in ScalaAzure Key Vault Integration in Scala
Azure Key Vault Integration in Scala
 
E.D.D.I - Open Source Chatbot Platform
E.D.D.I - Open Source Chatbot PlatformE.D.D.I - Open Source Chatbot Platform
E.D.D.I - Open Source Chatbot Platform
 
Appengine Java Night #2b
Appengine Java Night #2bAppengine Java Night #2b
Appengine Java Night #2b
 
#ajn3.lt.marblejenka
#ajn3.lt.marblejenka#ajn3.lt.marblejenka
#ajn3.lt.marblejenka
 
Appengine Java Night #2a
Appengine Java Night #2aAppengine Java Night #2a
Appengine Java Night #2a
 
OSMC 2014: MonitoringLove with Sensu | Jochen Lillich
OSMC 2014: MonitoringLove with Sensu | Jochen LillichOSMC 2014: MonitoringLove with Sensu | Jochen Lillich
OSMC 2014: MonitoringLove with Sensu | Jochen Lillich
 
Serverless APIs, the Good, the Bad and the Ugly (2019-09-19)
Serverless APIs, the Good, the Bad and the Ugly (2019-09-19)Serverless APIs, the Good, the Bad and the Ugly (2019-09-19)
Serverless APIs, the Good, the Bad and the Ugly (2019-09-19)
 

Andere mochten auch

Andere mochten auch (9)

GSOC 2008
GSOC 2008GSOC 2008
GSOC 2008
 
Gsoc2014
Gsoc2014Gsoc2014
Gsoc2014
 
GHOP - GSoC Campus Party 2008
GHOP - GSoC Campus Party 2008GHOP - GSoC Campus Party 2008
GHOP - GSoC Campus Party 2008
 
Participando Summer of Code
Participando Summer of CodeParticipando Summer of Code
Participando Summer of Code
 
Gsoc2012pdf
Gsoc2012pdfGsoc2012pdf
Gsoc2012pdf
 
GSoC en la UNI
GSoC en la UNIGSoC en la UNI
GSoC en la UNI
 
Gsoc2012
Gsoc2012Gsoc2012
Gsoc2012
 
A falta de APIs buenas son tortas. XV Betabeers Zaragoza
A falta de APIs buenas son tortas. XV Betabeers ZaragozaA falta de APIs buenas son tortas. XV Betabeers Zaragoza
A falta de APIs buenas son tortas. XV Betabeers Zaragoza
 
5 aniversario de Agile-Aragón
5 aniversario de Agile-Aragón5 aniversario de Agile-Aragón
5 aniversario de Agile-Aragón
 

Ähnlich wie Granada_Perl_Workshop_2014_Google_API_Client

Do you want a SDK with that API? (Nordic APIS April 2014)
Do you want a SDK with that API? (Nordic APIS April 2014)Do you want a SDK with that API? (Nordic APIS April 2014)
Do you want a SDK with that API? (Nordic APIS April 2014)Nordic APIs
 
WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015Fernando Daciuk
 
Silex meets SOAP & REST
Silex meets SOAP & RESTSilex meets SOAP & REST
Silex meets SOAP & RESTHugo Hamon
 
From Dev to DevOps - Apache Barcamp Spain 2011
From Dev to DevOps - Apache Barcamp Spain 2011From Dev to DevOps - Apache Barcamp Spain 2011
From Dev to DevOps - Apache Barcamp Spain 2011Carlos Sanchez
 
Introduction to Zend Framework web services
Introduction to Zend Framework web servicesIntroduction to Zend Framework web services
Introduction to Zend Framework web servicesMichelangelo van Dam
 
ZF2 for the ZF1 Developer
ZF2 for the ZF1 DeveloperZF2 for the ZF1 Developer
ZF2 for the ZF1 DeveloperGary Hockin
 
Iterators & generators: practical uses in memory management
Iterators & generators: practical uses in memory managementIterators & generators: practical uses in memory management
Iterators & generators: practical uses in memory managementAdrian Cardenas
 
ngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency InjectionngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency InjectionDzmitry Ivashutsin
 
Let's your users share your App with Friends: App Invites for Android
 Let's your users share your App with Friends: App Invites for Android Let's your users share your App with Friends: App Invites for Android
Let's your users share your App with Friends: App Invites for AndroidWilfried Mbouenda Mbogne
 
Passwords suck, but centralized proprietary services are not the answer
Passwords suck, but centralized proprietary services are not the answerPasswords suck, but centralized proprietary services are not the answer
Passwords suck, but centralized proprietary services are not the answerFrancois Marier
 
[AngularJS] From Angular to Mobile in 30 minutes
[AngularJS] From Angular to Mobile in 30 minutes[AngularJS] From Angular to Mobile in 30 minutes
[AngularJS] From Angular to Mobile in 30 minutesGlobant
 
Web::Machine - Simpl{e,y} HTTP
Web::Machine - Simpl{e,y} HTTPWeb::Machine - Simpl{e,y} HTTP
Web::Machine - Simpl{e,y} HTTPMichael Francis
 
Into the ZF2 Service Manager
Into the ZF2 Service ManagerInto the ZF2 Service Manager
Into the ZF2 Service ManagerChris Tankersley
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesLindsay Holmwood
 
Angular Tutorial Freshers and Experienced
Angular Tutorial Freshers and ExperiencedAngular Tutorial Freshers and Experienced
Angular Tutorial Freshers and Experiencedrajkamaltibacademy
 
Laravel Design Patterns
Laravel Design PatternsLaravel Design Patterns
Laravel Design PatternsBobby Bouwmann
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐいHisateru Tanaka
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswanivvaswani
 

Ähnlich wie Granada_Perl_Workshop_2014_Google_API_Client (20)

Do you want a SDK with that API? (Nordic APIS April 2014)
Do you want a SDK with that API? (Nordic APIS April 2014)Do you want a SDK with that API? (Nordic APIS April 2014)
Do you want a SDK with that API? (Nordic APIS April 2014)
 
WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015
 
Silex meets SOAP & REST
Silex meets SOAP & RESTSilex meets SOAP & REST
Silex meets SOAP & REST
 
From Dev to DevOps - Apache Barcamp Spain 2011
From Dev to DevOps - Apache Barcamp Spain 2011From Dev to DevOps - Apache Barcamp Spain 2011
From Dev to DevOps - Apache Barcamp Spain 2011
 
Introduction to Zend Framework web services
Introduction to Zend Framework web servicesIntroduction to Zend Framework web services
Introduction to Zend Framework web services
 
ZF2 for the ZF1 Developer
ZF2 for the ZF1 DeveloperZF2 for the ZF1 Developer
ZF2 for the ZF1 Developer
 
Iterators & generators: practical uses in memory management
Iterators & generators: practical uses in memory managementIterators & generators: practical uses in memory management
Iterators & generators: practical uses in memory management
 
Zend framework service
Zend framework serviceZend framework service
Zend framework service
 
Zend framework service
Zend framework serviceZend framework service
Zend framework service
 
ngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency InjectionngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency Injection
 
Let's your users share your App with Friends: App Invites for Android
 Let's your users share your App with Friends: App Invites for Android Let's your users share your App with Friends: App Invites for Android
Let's your users share your App with Friends: App Invites for Android
 
Passwords suck, but centralized proprietary services are not the answer
Passwords suck, but centralized proprietary services are not the answerPasswords suck, but centralized proprietary services are not the answer
Passwords suck, but centralized proprietary services are not the answer
 
[AngularJS] From Angular to Mobile in 30 minutes
[AngularJS] From Angular to Mobile in 30 minutes[AngularJS] From Angular to Mobile in 30 minutes
[AngularJS] From Angular to Mobile in 30 minutes
 
Web::Machine - Simpl{e,y} HTTP
Web::Machine - Simpl{e,y} HTTPWeb::Machine - Simpl{e,y} HTTP
Web::Machine - Simpl{e,y} HTTP
 
Into the ZF2 Service Manager
Into the ZF2 Service ManagerInto the ZF2 Service Manager
Into the ZF2 Service Manager
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
Angular Tutorial Freshers and Experienced
Angular Tutorial Freshers and ExperiencedAngular Tutorial Freshers and Experienced
Angular Tutorial Freshers and Experienced
 
Laravel Design Patterns
Laravel Design PatternsLaravel Design Patterns
Laravel Design Patterns
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
 

Kürzlich hochgeladen

SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 

Kürzlich hochgeladen (20)

SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 

Granada_Perl_Workshop_2014_Google_API_Client

  • 2. Who are you? Alberto Jesús Gutiérrez Juanes GDG Granada GDG Spain @aljesus_gj Granada Perl Workshop 2014
  • 4. HELP Granada Perl Workshop 2014 VERSIÓN 0.13 07/2011 Contribute to the project
  • 5. Granada Perl Workshop 2014 Perl? google-api- dotnet go java objectivec php python ruby -client
  • 6. Granada Perl Workshop 2014 What? AdSense Management API Analytics Blogger Calendar Plus URL Shortener WebFonts
  • 8. Granada Perl Workshop 2014 Why? OAuth provides client applications a 'secure delegated access' to server resources on behalf of a resource owner. It specifies a process for resource owners to authorize third-party access to their server resources without sharing their credentials.
  • 9. Granada Perl Workshop 2014 ● Lista Calendarios ● Lista Eventos ● Crear un evento ● Obtener un evento ● Actualizar un evento ● Eliminar un evento ● Mover un evento ● Obtener instancias ● ...
  • 10. Granada Perl Workshop 2014 use Google::API::Client; use Google::API::OAuth2::Client; use lib 'eg/lib'; use Sample::Utils qw/get_or_restore_token store_token/; use constant MAX_PAGE_SIZE => 50; my $client = Google::API::Client->new; my $service = $client->build('calendar', 'v3'); my $file = "$FindBin::Bin/../client_secrets.json"; my $auth_driver = Google::API::OAuth2::Client->new_from_client_secrets($file, $service->{auth_doc}); my $dat_file = "$FindBin::Bin/token.dat"; my $access_token = get_or_restore_token($dat_file, $auth_driver);
  • 11. Granada Perl Workshop 2014 # Call calendarlist.list my $res = $service->calendarList->list( body => { maxResults => MAX_PAGE_SIZE, minAccessRole => 'owner', } )->execute({ auth_driver => $auth_driver }); my $calendar_id = $res->{items}->[0]->{id}; my $dest_calendar_id = $res->{items}->[1]->{id};
  • 12. Granada Perl Workshop 2014 # Call events.list my $page_token; my $count = 1; do { say "=== page $count ==="; my %body = ( calendarId => $calendar_id, ); if ($page_token) { $body{pageToken} = $page_token; } $res = $service->events->list( body => %body, )->execute({ auth_driver => $auth_driver }); $page_token = $res->{nextPageToken}; for my $event (@{$res->{items}}) { say encode_utf8($event->{summary}); } $count++; } until (!$page_token);
  • 13. Granada Perl Workshop 2014 # Create a new event say '=== Create a new event ==='; my $new_event = { 'summary' => 'Appointment', 'location' => 'Somewhere', 'start' => { 'dateTime' => '2012-08-03T10:00:00+09:00', }, 'end' => { 'dateTime' => '2012-08-03T10:25:00+09:00', }, }; my $added_event = $service->events->insert( calendarId => $calendar_id, body => $new_event, )->execute({ auth_driver => $auth_driver }); say $added_event->{id};
  • 14. Granada Perl Workshop 2014 # Get an event say '=== Get a event ==='; my $got_event = $service->events->get( body => { calendarId => $calendar_id, eventId => $added_event->{id}, } )->execute({ auth_driver => $auth_driver }); say $got_event->{id}; # Update an event say '=== Update an event ==='; $got_event->{summary} = 'Appointment at Somewhere'; my $updated_event = $service->events->update( calendarId => $calendar_id, eventId => $got_event->{id}, body => $got_event, )->execute({ auth_driver => $auth_driver }); say $updated_event->{updated}; # Delete an event say '=== Delete an event ==='; my $deleted_event = $service->events->delete( calendarId => $calendar_id, eventId => $got_event->{id}, )->execute({ auth_driver => $auth_driver });
  • 15. Granada Perl Workshop 2014 use Google::API::Client; use OAuth2::Client; my $client = Google::API::Client->new; my $service = $client->build('plus', 'v1'); my $auth_driver = OAuth2::Client->new({ auth_uri => Google::API::Client->AUTH_URI, token_uri => Google::API::Client->TOKEN_URI, client_id => '<YOUR CLIENT ID>', client_secret => '<YOUR CLIENT SECRET>', redirect_uri => 'urn:ietf:wg:oauth:2.0:oob', auth_doc => $service->{auth_doc}, }); # people.get my $res = $service->people->get( body => { userId => 'me‘ })->execute({ auth_driver => $auth_driver });
  • 16. Granada Perl Workshop 2014 #!/usr/bin/perl use strict; use warnings; use feature qw/say/; use Data::Dumper; use URI; use Google::API::Client; my $service = Google::API::Client->new->build('urlshortener', 'v1'); my $url = $service->url; # Create a shortened URL by inserting the URL into the url collection. my $body = { 'longUrl' => 'http://code.google.com/apis/urlshortener/', }; my $res = $url->insert(body => $body)->execute; say Dumper($res); my $short_url = $res->{'id'}; # Convert the shortened URL back into a long URL $res = $url->get(body => { shortUrl => $short_url })->execute; say Dumper($res); __END__
  • 17. Granada Perl Workshop 2014 #!/usr/bin/perl use strict; use warnings; use feature qw/say/; use Data::Dumper; use URI; use Google::API::Client; use Google::API::OAuth2::Client; use lib 'eg/lib'; use Sample::Utils qw/get_or_restore_token store_token/; my $service = Google::API::Client->new->build('urlshortener', 'v1'); my $file = "$FindBin::Bin/../client_secrets.json"; my $auth_driver = Google::API::OAuth2::Client->new_from_client_secrets($file, $service->{auth_doc}); my $dat_file = "$FindBin::Bin/token.dat"; my $access_token = get_or_restore_token($dat_file, $auth_driver); my $url = $service->url; # Create a shortened URL by inserting the URL into the url collection. my $body = { 'longUrl' => 'http://code.google.com/apis/urlshortener/', }; my $res = $url->insert(body => $body)->execute; my $res = $url->insert(body => $body)->execute({ auth_driver => $auth_driver }); say Dumper($res); __END__ W ITH OAuth2
  • 18. What’s next? Getting Started with Google APIs Client code.google.com/p/google-api-perl-client/
  • 19. What’s next? Getting Started with Google APIs Client code.google.com/p/google-api-perl-client/