Codebase list flickcurl / upstream/1.2
upstream/1.2

Tree @upstream/1.2 (Download .tar.gz)

                    Flickcurl: C library for the Flickr API

[1]Dave Beckett

   Flickcurl is a C library for the [2]Flickr API, handling creating the
   requests, signing, token management, calling the API, marshalling
   request parameters and decoding responses. It uses [3]libcurl to call
   the [4]REST web service and [5]libxml2 to manipulate the XML responses.
   Flickcurl 1.0 or later supports 100% of the 2008-01-23 version of the
   API (see [6]Flickcurl API coverage) including the functions for photo
   uploading, browsing, searching, adding and editing comments, groups,
   notes, photosets, categories, activity, blogs, favorites, places, tags
   and photo metadata. It also includes a program flickrdf to turn photo
   metadata, tags and machine tags into RDF descriptions of photso and
   tags.

   License: LGPL 2.1 / GPL 2 / Apache 2.0

   Download: [7]http://download.dajobe.org/flickcurl/

   News: [8]Flickcurl News including changes

   Requirements: the following libraries are needed:
     * [9]libcurl 7.10.0 or newer
     * [10]libxml2 2.6.8 or newer
     * [11]raptor 1.4.0 (optional), 1.4.14 recommended

   Then do the usual ./configure, make and make install sequence to
   install the library and the flickcurl and flickrdf utilities.

   Subversion [12]browse with viewVC or checkout with:
  svn co http://svn.dajobe.org/repositories/flickcurl/trunk/ flickcurl

Flickr API Configuration

   The library needs to know your Flickr API application key,
   authentication token and shared secret, suitable for calling some of
   the API calls. To obtain these, you need to [13]apply for API keys at
   the Flickr Services site. When using the utility programs, this
   information should be stored in the ~/.flickcurl.conf file so that it
   can be read at run-time. The configuration file has the format:
[flickr]
auth_token=1234567-8901234567890123
api_key=0123456789abcdef0123456789abcdef
secret=fedcba9876543210

Utility programs

  flickcurl - call Flickr API

   This can call some of the Flickr APIs plus help with authentication by
   turning [14]mobile authentication method frobs into full auth_tokens
   with -a NNN-NNN-NNN and writing the ~/.flickcurl.conf file. Use
   flickcurl -h to get a list of the supported commands and their
   arguments.

   This example calls the [15]photos.getInfo API via the photos-getInfo
   command on photo 196308964 which decodes the returned XML into fields
   in a flickcurl_photo structure which are then printed with their
   datatype, string value and integer value (or -1 if it has none). All
   dateTime values are converted into both the ISO format string (such as
   used by Web and XML standards) and unix time integers. Photo tags are
   also returned when present along with their id, author, raw, cooked and
   machine tag status.
$ flickcurl photos-getInfo 196308964
flickcurl: Found photo with URI http://www.flickr.com/photos/dajobe/196308964/ I
D 196308964 and 5 tags
field dateuploaded (1) with dateTime value: '2006-07-23T18:16:13Z' / 1153678573
field farm (2) with integer value: '1' / 1
field isfavorite (3) with boolean value: '0' / 0
field license (4) with integer value: '1' / 1
field originalformat (5) with string value: 'jpg' / -1
field rotation (6) with integer value: '0' / 0
field server (7) with integer value: '57' / 57
field dates_lastupdate (8) with dateTime value: '2007-02-25T07:45:46Z' / 1172389
546
field dates_posted (9) with dateTime value: '2006-07-23T18:16:13Z' / 1153678573
field dates_taken (10) with dateTime value: '2006-07-23T05:28:50Z' / 1153632530
field dates_takengranularity (11) with integer value: '0' / 0
field editability_canaddmeta (13) with boolean value: '1' / 1
field editability_cancomment (14) with boolean value: '1' / 1
field geoperms_iscontact (15) with boolean value: '0' / 0
field geoperms_isfamily (16) with boolean value: '0' / 0
field geoperms_isfriend (17) with boolean value: '0' / 0
field geoperms_ispublic (18) with boolean value: '1' / 1
field location_accuracy (19) with integer value: '12' / 12
field location_latitude (20) with float value: '36.620487' / -1
field location_longitude (21) with float value: '-121.904468' / -1
field owner_location (22) with string value: 'USA' / -1
field owner_nsid (23) with string value: '13355580@N00' / -1
field owner_realname (24) with string value: 'Dave Beckett' / -1
field owner_username (25) with string value: 'dajobe' / -1
field title (26) with string value: 'Jellyfish at Monterey Aquarium' / -1
field visibility_isfamily (27) with boolean value: '0' / 0
field visibility_isfriend (28) with boolean value: '0' / 0
field visibility_ispublic (29) with boolean value: '1' / 1
field secret (30) with string value: '**********' / -1
field originalsecret (31) with string value: '**********' / -1
field location_locality (33) with string value: 'Pacific Grove' / -1
field location_region (35) with string value: 'California' / -1
field location_country (36) with string value: 'United States' / -1
field location_placeid (37) with string value: 'WM3JEXSbBZqqRtGA' / -1
field locality_placeid (39) with string value: 'WM3JEXSbBZqqRtGA' / -1
field county_placeid (40) with string value: 'AQ4UpRqYA5l0BiyF.A' / -1
field region_placeid (41) with string value: 'SVrAMtCbAphCLAtP' / -1
field country_placeid (42) with string value: '4KO02SibApitvSBieQ' / -1
0) regular tag: id 94493-196308964-3362 author ID 13355580@N00 name (Unknown) ra
w 'jellyfish' cooked 'jellyfish' count 0
1) regular tag: id 94493-196308964-119180 author ID 13355580@N00 name (Unknown)
raw 'montereyaquarium' cooked 'montereyaquarium' count 0
2) regular tag: id 94493-196308964-2443 author ID 13355580@N00 name (Unknown) ra
w 'monterey' cooked 'monterey' count 0
3) machine tag: id 94493-196308964-8499312 author ID 13355580@N00 name (Unknown)
 raw 'xmlns:dc=http://purl.org/dc/elements/1.1/' cooked 'xmlns:dc=httppurlorgdce
lements11' count 0
4) machine tag: id 94493-196308964-8499315 author ID 13355580@N00 name (Unknown)
 raw 'dc:subject=jellyfish' cooked 'dc:subject=jellyfish' count 0
0) place location: id WM3JEXSbBZqqRtGA
2) place locality: name 'Pacific Grove' id WM3JEXSbBZqqRtGA
3) place county: name 'Monterey' id AQ4UpRqYA5l0BiyF.A
4) place region: name 'California' id SVrAMtCbAphCLAtP
5) place country: name 'United States' id 4KO02SibApitvSBieQ

  flickrdf - generate RDF triples from a Flickr photo

   This utility uses the photos.getInfo API to interpret the description
   fields and the tags for a photo URI into RDF triples. If [16]raptor is
   present, it will be used to provide proper serializing to RDF rather
   than the built in and hacky ntriples/turtle output.

   Machine tags when they are found are scanned for xmlns:prefix=uri and
   then all other machine tags with that prefix turn into triples. Several
   prefixes are also pre-defined by the library to automatically get
   turned into triples without an xmlns, such as blue:, cell:, filter: and
   geo:. Non-machine tags are not yet interpreted.
$ flickrdf http://www.flickr.com/photos/dajobe/196308964/
<http://www.flickr.com/photos/dajobe/196308964/> <http://purl.org/dc/elements/1.
1/creator> _:person .
_:person <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foa
f/0.1/#Person> .
_:person <http://xmlns.com/foaf/0.1/#maker> <http://www.flickr.com/photos/dajobe
/196308964/> .
<http://www.flickr.com/photos/dajobe/196308964/> <http://purl.org/dc/elements/1.
1/dateSubmitted> "2006-07-23T18:16:13Z"^^<http://www.w3.org/2001/XMLSchema#dateT
ime> .
<http://www.flickr.com/photos/dajobe/196308964/> <http://purl.org/dc/elements/1.
1/rights> <http://creativecommons.org/licenses/by-nc-sa/2.0/> .
<http://www.flickr.com/photos/dajobe/196308964/> <http://purl.org/dc/elements/1.
1/modified> "2007-02-25T07:45:46Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>
.
<http://www.flickr.com/photos/dajobe/196308964/> <http://purl.org/dc/elements/1.
1/issued> "2006-07-23T18:16:13Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
<http://www.flickr.com/photos/dajobe/196308964/> <http://purl.org/dc/elements/1.
1/created> "2006-07-23T05:28:50Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
<http://www.flickr.com/photos/dajobe/196308964/> <http://www.w3.org/2003/01/geo/
wgs84_pos#lat> "36.620487" .
<http://www.flickr.com/photos/dajobe/196308964/> <http://www.w3.org/2003/01/geo/
wgs84_pos#long> "-121.904468" .
_:person <http://xmlns.com/foaf/0.1/#name> "Dave Beckett" .
_:person <http://xmlns.com/foaf/0.1/#nick> "dajobe" .
<http://www.flickr.com/photos/dajobe/196308964/> <http://purl.org/dc/elements/1.
1/title> "Jellyfish at Monterey Aquarium" .
<http://www.flickr.com/photos/dajobe/196308964/> <http://purl.org/dc/elements/1.
1/subject> "jellyfish" .

   If you have raptor installed, you can get nicer RDF triples out and
   with rapper 1.4.14+, pretty-printed turtle:
$ flickrdf -o turtle http://www.flickr.com/photos/dajobe/196308964/
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/#> .
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://www.flickr.com/photos/dajobe/196308964/>
    dc:creator [
        a foaf:Person ;
        foaf:maker <http://www.flickr.com/photos/dajobe/196308964/> ;
        foaf:name "Dave Beckett" ;
        foaf:nick "dajobe"
    ] ;
    dc:dateSubmitted "2006-07-23T18:16:13Z"^^xsd:dateTime ;
    dc:rights <http://creativecommons.org/licenses/by-nc-sa/2.0/> ;
    dc:modified "2007-02-25T07:45:46Z"^^xsd:dateTime ;
    dc:issued "2006-07-23T18:16:13Z"^^xsd:dateTime ;
    dc:created "2006-07-23T05:28:50Z"^^xsd:dateTime ;
    geo:lat "36.620487" ;
    geo:long "-121.904468" ;
    dc:title "Jellyfish at Monterey Aquarium" ;
    dc:subject "jellyfish" .


Library use example

   See example.c
#include <stdio.h>
#include <flickcurl.h>

int main() {
  flickcurl *fc;
  flickcurl_photo *photo;
  flickcurl_photo_field field;
  int i;

  flickcurl_init(); /* optional static initialising of resources */

  fc=flickcurl_new();

  /* Set configuration, or more likely read from a config file */
  flickcurl_set_api_key(fc, "...");
  flickcurl_set_shared_secret(fc, "...");
  flickcurl_set_auth_token(fc, "...");

  photo=flickcurl_photos_getInfo(fc, "123456789"); /* photo ID */

  for(field=0; field <= PHOTO_FIELD_LAST; field++) {
    flickcurl_field_value_type datatype=photo->fields[field].type;

    if(datatype != VALUE_TYPE_NONE)
      fprintf(stderr, "field %s (%d) with %s value: '%s' / %d\n",
              flickcurl_get_photo_field_label(field), field,
              flickcurl_get_field_value_type_label(datatype),
              photo->fields[field].string, photo->fields[field].integer);
  }

  for(i=0; i < photo->tags_count; i++) {
    flickcurl_tag* tag=photo->tags[i];
    fprintf(stderr, "%d) %s tag: id %s author %s raw '%s' cooked '%s'\n",
            i, (tag->machine_tag ? "machine" : "regular"),
            tag->id, tag->author, tag->raw, tag->cooked);
  }

  flickcurl_free_photo(photo);

  flickcurl_free(fc);

  flickcurl_finish(); /* optional static free of resources */
}

   For more extensive example code, see the source of the flickcurl
   utility in flickcurl.c which has code that calls all the API functions.
     __________________________________________________________________

   Copyright (C) 2007-2008 [17]Dave Beckett

References

   1. http://www.dajobe.org/
   2. http://www.flickr.com/services/api/
   3. http://curl.haxx.se/libcurl/
   4. http://www.flickr.com/services/api/request.rest.html
   5. http://xmlsoft.org/
   6. file://localhost/home/dajobe/dev/redland/flickcurl/coverage.html
   7. http://download.dajobe.org/flickcurl/
   8. file://localhost/home/dajobe/dev/redland/flickcurl/NEWS.html
   9. http://curl.haxx.se/libcurl/
  10. http://xmlsoft.org/
  11. http://librdf.org/raptor/
  12. http://svn.dajobe.org/view/
  13. http://www.flickr.com/services/api/keys/apply/
  14. http://www.flickr.com/services/api/auth.howto.mobile.html
  15. http://www.flickr.com/services/api/flickr.photos.getInfo.html
  16. http://librdf.org/raptor/
  17. http://www.dajobe.org/