This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| perl_client_library [2010/11/06 18:45] – jay | perl_client_library [2011/11/10 19:34] (current) – jay | ||
|---|---|---|---|
| Line 4: | Line 4: | ||
| This simple implementation illustrates how to use a low-level HTTP library to provide an object-oriented interface to the 4theFile API functionality. The users of the resulting module don't need to think about REST or HTTP; their interface is practically identical to what they would see if the 4theFile Resource data was stored in a local database on their server. | This simple implementation illustrates how to use a low-level HTTP library to provide an object-oriented interface to the 4theFile API functionality. The users of the resulting module don't need to think about REST or HTTP; their interface is practically identical to what they would see if the 4theFile Resource data was stored in a local database on their server. | ||
| - | If you're a perl programmer, you could use this library as is or modify it to suit your tastes. Or you might want to use this perl implementation as a model for your own development in the language of your choice. | + | If you're a perl programmer, you could use this library as is, or modify it to suit your tastes. Or you might want to use the perl implementation as a model for your own development in the language of your choice. |
| + | |||
| + | [[http:// | ||
| < | < | ||
| Line 13: | Line 15: | ||
| SYNOPSIS | SYNOPSIS | ||
| use Lib4theFileAPI; | use Lib4theFileAPI; | ||
| - | my $api = Lib4theFileAPI-> | + | my $api = Lib4theFileAPI-> |
| + | | ||
| + | $api-> | ||
| # list resources for collection ESuVkqZF that have tag " | # list resources for collection ESuVkqZF that have tag " | ||
| Line 29: | Line 33: | ||
| returns a new Lib4theFileAPI instance | returns a new Lib4theFileAPI instance | ||
| + | |||
| + | version() | ||
| + | returns VERSION string for perl library | ||
| INSTANCE METHODS | INSTANCE METHODS | ||
| - | response(); | + | response() |
| returns an HTTP:: | returns an HTTP:: | ||
| 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-> | ||
| + | from the http connection), | ||
| + | the server | ||
| resource_list([$query]) | resource_list([$query]) | ||
| Line 46: | Line 59: | ||
| returns Lib4theFileAPI:: | returns Lib4theFileAPI:: | ||
| undef if none found | undef if none found | ||
| + | |||
| + | resource_attachment_list($rkey) | ||
| + | returns a Lib4thFile:: | ||
| + | for the top-level message in Resource, plus a little meta data (e.g. attach- | ||
| + | ment_count) | ||
| collection_resource_list($ckey, | collection_resource_list($ckey, | ||
| Line 52: | Line 70: | ||
| $query is an optional hashref containing query parameters as | $query is an optional hashref containing query parameters as | ||
| - | outlined in the API documentation. keys include page, per_page, tag | + | outlined in the API documentation. keys include page, per_page, tag, cdate |
| collection($ckey) | collection($ckey) | ||
| Line 78: | 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: | ||
| </ | </ | ||