This shows you the differences between two versions of the page.
perl_client_library [2010/12/06 15:56] jay |
perl_client_library [2011/11/10 19:34] (current) jay |
||
---|---|---|---|
Line 15: | Line 15: | ||
SYNOPSIS | SYNOPSIS | ||
use Lib4theFileAPI; | use Lib4theFileAPI; | ||
- | my $api = Lib4theFileAPI->new('https://4thefile.com/api_v1',$username,$apiKey); | + | my $api = Lib4theFileAPI->new(’https://4thefile.com/api_v1’,$username,$apiKey) |
+ | ││ die "invalid endpoint url or credentials"; | ||
+ | $api->test_connect or die "failed api connection with error: ".$api->response->status_line; | ||
# list resources for collection ESuVkqZF that have tag "newtag" | # list resources for collection ESuVkqZF that have tag "newtag" | ||
Line 36: | Line 38: | ||
INSTANCE METHODS | INSTANCE METHODS | ||
- | response(); | + | response() |
returns an HTTP::Response object resulting from previous API call, | returns an HTTP::Response object resulting from previous API call, | ||
especially useful if previous call returned undef indicating a | especially useful if previous call returned undef indicating a | ||
problem | problem | ||
+ | |||
+ | test_connect() | ||
+ | attempts a call to the resource_list API method and returns 1 if connection was successful and valid data | ||
+ | received. returns undef if connection failed (use response->status_line to see the error code returned | ||
+ | from the http connection), or returns 0 if the connection was successful but no valid xml was returned by | ||
+ | the server | ||
resource_list([$query]) | resource_list([$query]) | ||
Line 51: | Line 59: | ||
returns Lib4theFileAPI::Resource object for resource key $rkey or | returns Lib4theFileAPI::Resource object for resource key $rkey or | ||
undef if none found | undef if none found | ||
+ | |||
+ | resource_attachment_list($rkey) | ||
+ | returns a Lib4thFile::AttachmentList object containing a list of attachments (if any) | ||
+ | for the top-level message in Resource, plus a little meta data (e.g. attach- | ||
+ | ment_count) | ||
collection_resource_list($ckey,[$query]) | collection_resource_list($ckey,[$query]) | ||
Line 83: | Line 96: | ||
does not delete resource from 4theFile. | does not delete resource from 4theFile. | ||
- | AUTHOR | ||
- | created by: jay; Fri Nov 5 16:58:42 2010 | ||
- | |||
- | last revised: | ||
</code> | </code> |