VUser:...::V2_0(3pm)

πŸ“¦
version 1.0.1 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– VUser:...::V2_0 πŸ’–

okay bestie, welcome to VUser:...::V2_0, aka VUser::Google::ApiProtocol::V2_0 β€” it's a user-contributed Perl thing (manual section 3pm, the Perl module pages, iykyk) and it's literally just... version 2.0 of the Google APIs, implemented. that's the whole vibe. ✨


🌸 NAME 🌸

VUser::Google::ApiProtocol::V2_0 β€” bestie, this module Implements version 2.0 of the Google APIs. no cap, that's it, that's the job. πŸ’…


πŸŽ€ SYSNOPSIS πŸŽ€

here's how you actually use it, copied exactly so you can just paste and go:

 use VUser::Google::ApiProtocol::V2_0;

 ## Create a new connection
 my $google = VUser::Google::ApiProtocol::V2_0->new(
     domain   => 'your.google-apps-domain.com',
     admin    => 'admin_user',
     password => 'admin_user password',
 );

 ## Login to the Google Apps API
 # Login() uses the credentials provided in new()
 $google->Login();

 ## Create a new request
 # Create the URL to send to API request to.
 # See the API docs for the valid URLs
 my $url = "https://apps-apis.google.com/a/feeds/emailsettings/2.0/"
 $url   .= "your.google-apps-domain.com/username/label";

 # Create XML message to send to Google
 # See the API docs for the valid XML to send
 my $xml = '<?xml version="1.0" encoding="utf-8"?>...';

 # NB: The method (POST here) may be different depending on API call
 my $success = $google->Request('POST', $url, $xml);

 # Get the parsed response
 if ($success) {
     # $result is the XML reply parsed by XML::Simple
     my $result = $google->get_result;
 }
 else {
     # $result is the error message from google
     # parsed by XML::Simple with the addition of a
     # 'reason' key which contains the error.
     my $result = $google->get_result;
     die "Error: $result->{reason}";
 }

so real talk about what's happening up there 🫢:

  • you spin up a new connection with new(), passing your domain, your admin, and your password.
  • then Login() logs you in β€” and heads up, it uses the credentials you already handed to new().
  • then you build your $url, build your $xml, and fire it off with Request(). the HTTP method (it's POST in the example) can be different depending on which API call you're making, so check the docs.
  • if it worked, get_result gives you the XML reply parsed by XML::Simple. if it flopped, you still get a result β€” the error message from google, also parsed by XML::Simple, except with an extra 'reason' key holding the error. that's the one you die on. πŸ’€

✨ DESCRIPTION ✨

so like. this module Implements version 2.0 of the Google API. and for the full rundown of members and methods, you're gonna wanna go look at VUser::Google::ApiProtocol β€” that's where the whole list lives. periodt. πŸ‘‘


πŸ¦‹ SEE ALSO πŸ¦‹

  • VUser::Google::ApiProtocol
  • XML::Simple

πŸ’œ AUTHOR πŸ’œ

Randy Smith <perlstalker@vuser.org>

Adapted from code from Johan Reinalda <johan@reinalda.net>


🌈 LICENSE 🌈

Copyright (C) 2006 by Johan Reinalda, johan at reinalda dot net

Copyright (C) 2009 by Randy Smith, perlstalker at vuser dot org

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.

If you make useful modification, kindly consider emailing then to me for inclusion in a future version of this module.


πŸ’– if you make useful modification, kindly consider emailing then to me for inclusion in a future version of this module β€” that's literally the original asking, bestie, go be a main character and send it in.

and that's a wrap! this page ships as perl v5.32.0, dated 2021-01-09 β€” the version and the date are right there, frozen in time like a screenshot from 2021. slay. πŸŽ€βœ¨πŸŒΈ

πŸ“¦ where this page comes from