NAME
XML::Loy::ActivityStreams - ActivityStreams Extension for Atom
SYNOPSIS
# Create new Atom object
my $atom = XML::Loy::Atom->new('feed');
# Extend with ActivityStreams
$atom->extension(-ActivityStreams);
# New atom entry
my $entry = $atom->entry(id => 'first_post');
for ($entry) {
# Define activity actor
$_->actor(name => 'Fry');
# Define activity verb
$_->verb('loves');
# Define activity object
$_->object(
'object-type' => 'person',
'name' => 'Leela'
)->title('Captain');
# Set related Atom information
$_->title(xhtml => 'Fry loves Leela');
$_->summary("Now it's official!");
$_->published(time);
};
# Retrive verb
print $entry->verb;
# Print ActivityStream as XML
print $atom->to_pretty_xml;
# <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
# <feed xmlns="http://www.w3.org/2005/Atom"
# xmlns:activity="http://activitystrea.ms/schema/1.0/">
# <entry xml:id="first_post">
# <id>first_post</id>
# <author>
# <name>Fry</name>
# <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
# </author>
# <activity:verb>http://activitystrea.ms/schema/1.0/loves</activity:verb>
# <activity:object>
# <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
# <name>Leela</name>
# <title xml:space="preserve"
# xmlns="http://www.w3.org/2005/Atom">Captain</title>
# </activity:object>
# <title type="xhtml">
# <div xmlns="http://www.w3.org/1999/xhtml">Fry loves Leela</div>
# </title>
# <summary xml:space="preserve">Now it's official!</summary>
# <published>2013-03-08T14:01:14Z</published>
# </entry>
# </feed>
DESCRIPTION
XML::Loy::ActivityStreams is an extension to XML::Loy::Atom and provides additional functionality for the work with Atom ActivityStreams.
This module is an early release! There may be significant changes in the future.
METHODS
XML::Loy::ActivityStreams inherits all methods from XML::Loy and implements the following new ones.
actor
my $person = $atom->new_person(
name => 'Bender',
uri => 'acct:bender@example.org'
);
my $actor = $atom->actor($person);
print $atom->actor->at('name')->text;
Sets the actor of the ActivityStreams object or returns it. Accepts a person construct (see new_person) or the parameters accepted by new_person.
verb
$atom->verb('follow');
print $atom->verb;
Sets the verb of the ActivityStreams object or returns it. Accepts a verb string. Relative verbs will be prefixed with the ActivityStreams namespace.
object
$atom->object(
'object-type' => 'person',
'displayName' => 'Leela'
);
print $atom->object->at('object-type')->text;
Sets object information to the ActivityStreams object or returns it. Accepts a hash with various parameters depending on the object's type. The object's type is given by the object-type
parameter. Relative object types will be prefixed with the ActivityStreams namespace.
target
$atom->target(
'object-type' => 'robot',
'displayName' => 'Bender'
);
print $atom->target->at('object-type')->text;
Sets target information to the ActivityStreams object or returns it. Accepts a hash with various parameters depending on the target's type. The target's type is given by the object-type
parameter. Relative object types will be prefixed with the ActivityStreams namespace.
DEPENDENCIES
LIMITATIONS
XML::Loy::ActivityStreams has currently no support for JSON serialization, neither on reading nor writing.
AVAILABILITY
https://github.com/Akron/XML-Loy
COPYRIGHT AND LICENSE
Copyright (C) 2011-2016, Nils Diewald.
This program is free software, you can redistribute it and/or modify it under the same terms as Perl.