~ubuntu-branches/debian/sid/flickcurl/sid

« back to all changes in this revision

Viewing changes to examples/print-photo-info.c

  • Committer: Package Import Robot
  • Author(s): Kumar Appaiah
  • Date: 2013-05-20 21:15:09 UTC
  • mfrom: (1.4.1) (15.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130520211509-e701o5dlwa04aqiw
Tags: 1.24-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * print-photo-info.c - Flickcurl example code to get information about a photo
3
3
 *
4
 
 * This is example code and not complete because the API Key, Shared
5
 
 * Secret and Auth Token are not configured.  The flickcurl utility
6
 
 * in utils/flickcurl.c contains code that fully uses the API.
 
4
 * This is example code and not complete because the OAuth client
 
5
 * key, secret and the token and token secret are not configured.
 
6
 *
 
7
 * The flickcurl utility in utils/flickcurl.c contains code that
 
8
 * fully uses the API and read/writes configuration from a file
 
9
 * using flickcurl_config_var_handler()
7
10
 *
8
11
 * This file is in the Public Domain
9
12
 *
26
29
  int i;
27
30
 
28
31
  flickcurl_init(); /* optional static initialising of resources */
29
 
  fc=flickcurl_new();
30
 
 
31
 
  /* Set configuration, or more likely read from a config file */
32
 
  flickcurl_set_api_key(fc, "...");
33
 
  flickcurl_set_shared_secret(fc, "...");
34
 
  flickcurl_set_auth_token(fc, "...");
35
 
 
36
 
  photo=flickcurl_photos_getInfo(fc, "123456789"); /* photo ID */
37
 
 
38
 
  for(field_type=0; field_type <= PHOTO_FIELD_LAST; field_type++) {
39
 
    flickcurl_field_value_type datatype=photo->fields[field_type].type;
 
32
  fc = flickcurl_new();
 
33
 
 
34
  /* Set configuration explicitly: ... */
 
35
  flickcurl_set_oauth_client_key(fc, "...");
 
36
  flickcurl_set_oauth_client_secret(fc, "...");
 
37
  flickcurl_set_oauth_token(fc, "...");
 
38
  flickcurl_set_oauth_token_secret(fc, "...");
 
39
 
 
40
  /* or could read from an INI config file like this: */
 
41
  /*
 
42
  flickcurl_config_read_ini(fc, "/home/user/.flickcurl.conf", "flickr",
 
43
                            fc, flickcurl_config_var_handler);
 
44
  */  
 
45
 
 
46
 
 
47
  photo = flickcurl_photos_getInfo(fc, "123456789"); /* photo ID */
 
48
 
 
49
  for(field_type = 0; field_type <= PHOTO_FIELD_LAST; field_type++) {
 
50
    flickcurl_field_value_type datatype = photo->fields[field_type].type;
40
51
    
41
52
    if(datatype != VALUE_TYPE_NONE)
42
53
      fprintf(stderr, "field %s (%d) with %s value: '%s' / %d\n", 
46
57
              photo->fields[field_type].integer);
47
58
  }
48
59
 
49
 
  for(i=0; i < photo->tags_count; i++) {
 
60
  for(i = 0; i < photo->tags_count; i++) {
50
61
    flickcurl_tag* tag=photo->tags[i];
51
62
    fprintf(stderr,
52
63
            "%d) %s tag: id %s author ID %s name %s raw '%s' cooked '%s' count %d\n",