
Net::Zemanta::Suggest - Perl interface to Zemanta Suggest service

use Net::Zemanta::Suggest;
my $zemanta = Net::Zemanta::Suggest->new(
APIKEY => 'your-API-key'
);
my $suggestions = $zemanta->suggest(
"Cozy lummox gives smart squid who asks for job pen."
);
# Suggested images
for $image (@{$suggestions->{images}}) {
$image->{url_m};
$image->{description};
}
# Related articles
for $article (@{$suggestions->{articles}}) {
$article->{url};
$article->{title};
}
# In-text links
for $link (@{$suggestions->{markup}->{links}}) {
for $target (@{$link->{target}}) {
$link->{anchor}, " -> ", $target->{url};
}
}
# Keywords
for $keyword (@{$suggestions->{keywords}}) {
$keyword->{name};
}

Net::Zemanta::Suggest->new(PARAM => ...);
Acceptable parameters:
The API key used for authentication with the service.
If set to true, a faster variant of the API call is made that only returns the markup element. Default is to provide everything (images, related articles, markup and tags).
If supplied the value is prepended to this module's identification string to become something like:
your-killer-app/0.042 Perl-Net-Zemanta/0.1 libwww-perl/5.8
Otherwise just Net::Zemanta's user agent string will be sent.
new() returns undef on error.
$suggestions = $zemanta->suggest( text, PARAM => ... )
Requests suggestions for the given text. Suggestions are returned as a tree of hash and list references that correspond to the returned JSON data structure. The most important elements are described bellow. For the full reference see http://developer.zemanta.com.
Optional parameters:
Set to 1 to include FreeBase (http://www.freebase.com) GUIDs with in-text markup.
suggest() returns undef on error.
Related articles. Contains a list of article objects, each having the following elements:
URL of the article.
Title of the article.
Date when article was published in ISO 8601 format.
Suggested keywords. Contains a list of keyword objects, each having the following elements:
Keyword name (may contain spaces)
Related images. Contains a list of image objects, each having the following elements:
URLs of a large, medium and small version of the picture respectively.
Width and height of large, medium and small version of the picture respectively.
String containing license terms.
String containing description
Attribution that must be posted together with the image.
URL of a web page where more information about the image can be found.
An object containing the following elements:
HTML formatted input text with added in-text hyperlinks.
Suggested in-text hyperlinks. A list of link objects, each having the following elements:
Word or phrase in the original text that should be used as the anchor for the link.
List of possible targets for this link. Each target has the following elements:
FreeBase GUID (if suggest() was called with FreeBase support enabled)
Request ID.
HTML signature that should be appended to the text.
If the last call to suggest() returned an error, this function returns a string containing a short description of the error. Otherwise it returns undef.


Tomaz Solc <tomaz@zemanta.com>

Copyright (C) 2008 by Zemanta ltd.
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.7 or, at your option, any later version of Perl 5 you may have available.