Rob Brown > WebService-Search123-0.09 > WebService::Search123

Download:
WebService-Search123-0.09.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.09   Source  

NAME ^

WebService::Search123 - Interface to the Search123 XML API.

VERSION ^

Version 0.06

SYNOPSIS ^

The Search123 XML API interface.

Configure the call with new(), supplying your account details, keywords, etc. then calling ads to make the actual call.

 use WebService::Search123;

 my $s123 = WebService::Search123->new( aid => 99999 );
 
 foreach my $ad ( $s123->ads )
 {
    print $ad->title;
    print $ad->description;
    print $ad->url->as_string;           # url is a URI object
    print $ad->display_url;              # probably not a valid URL
    print $ad->favicon_url->as_string;   # if available
 }

The list of ads returned with ads is remembered, so only one call is made.

If options are changed with the methods below, the list will be cleared and re-requested when calling ads again.

DESCRIPTION ^

Interface to the Search123 platform for searching for ads.

 use WebService::Search123;
 
 $WebService::Search123::DEBUG = 1;
 
 my $s123 = WebService::Search123->new(
     aid      => 10057,
     keyword  => 'ipod',
     per_page => 5,
     client   => {
         ip   => '88.208.204.52',
         ua   => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8)',
         ref  => 'http://www.ultimatejujitsu.com/jujitsu-for-beginners/',
     },
 );
 
 binmode STDOUT, ":encoding(UTF-8)";
 
 foreach my $ad ( $s123->ads )
 {
     print $ad->title . "\n";
 }

 # change the keyword and get new ads

 $s123->keyword( 'phone' );

 foreach my $ad ( $s123->ads ) { ... }

METHODS ^

Attributes

ua

 $s123->ua

The internal LWP::UserAgent to use.

The default user-agent has an identifier string of 'WebService-Search123/$VERSION', where $VERSION is the version of this module.

secure

 $s123->secure( 1 );

Flag to indicate whether to use https or http (default).

aid

 $s123->aid( 99999 );

Your account ID with Search123.

keyword

The user-supplied keywords to search against.

 $s123->keyword( 'ipod' );

per_page

The number of results requested.

 $s123->per_page( 5 );

ads

The returned list of ad objects based on the criteria supplied.

See WebService::Search123::Ad for details on these objects.

 foreach my $ad ( $s123->ads ) { ... }

client

A hash-reference containing details about your end-user, including IP address, user-agent string, and the page they're on to view the ads.

You should set this at construction time.

Set and get methods are available as set_client() and get_client().

 $s123->set_client( ip => '127.0.0.1' );

 $s123->get_client( 'ua' );

session

The session string/cookie to send with each request.

You should store this in a cookie and re-use it for 30 minutes as per the Search123 documentation.

 $s123->session

request_time

How long the underlying HTTP API request took.

 $s123->request_time;
syntax highlighting: