GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Net::Twitter::Role::InflateObjects(3) User Contributed Perl Documentation Net::Twitter::Role::InflateObjects(3)

Net::Twitter::Role::InflateObjects - Inflate Twitter API return values to Moose objects

version 4.01043

  use Net::Twitter;
  my $nt = Net::Twitter->new(traits => [qw/InflateObjects API::Rest/]);

  $nt->credentials($username, $password);

  $r = $nt->friends_timeline;

  $r->[0]->user->name; # return values are objects with read accessors
  $r->[0]->created_at; # dates are inflated to DateTime objects
  $r->[0]->relative_created_at; # "6 minutes ago"

This role provides inflation of HASH refs, returned by the Twitter API, into Moose objects. URLs are inflated to URI objects. Dates are inflated to DateTime objects. Objects that have a "created_at" attribute also have a "relative_created_at" method that prints times in the same style as the Twitter web interface.

All HASH members have read accessors, so

  $r->[0]->{user}{screen_name}

Can be accessed as

  $r->[0]->user->screen_name

An accessor is created for each HASH key returned by Twitter. As Twitter adds new attributes, InflateObjects will create accessors for them. However, InflateObjects will also drop accessors if Twitter drops the corresponding HASH element. So, code that relies on HASH element will fail loudly if Twitter drops support for it. (This may be a feature!)

Marc Mims <marc@questright.com>

Copyright (c) 2016 Marc Mims

The Twitter API itself, and the description text used in this module is:

Copyright (c) 2009 Twitter

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

2018-01-17 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.