Пример #1
0
/**
 * flickcurl_photosets_comments_editComment:
 * @fc: flickcurl context
 * @comment_id: The id of the comment to edit.
 * @comment_text: Update the comment to this text.
 * 
 * Edit the text of a comment as the currently authenticated user.
 *
 * Implements flickr.photosets.comments.editComment (0.10)
 * 
 * Return value: non-0 on failure
 **/
int
flickcurl_photosets_comments_editComment(flickcurl* fc,
                                         const char* comment_id,
                                         const char* comment_text)
{
  xmlDocPtr doc = NULL;
  int result = 1;
  
  flickcurl_init_params(fc, 1);

  if(!comment_id || !comment_text)
    return 1;

  flickcurl_add_param(fc, "comment_id", comment_id);
  flickcurl_add_param(fc, "comment_text", comment_text);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.photosets.comments.editComment"))
    goto tidy;

  doc = flickcurl_invoke(fc);
  if(!doc)
    goto tidy;

  result = 0;

  tidy:
  if(fc->failed)
    result = 1;

  return result;
}
Пример #2
0
/**
 * flickcurl_interestingness_getList_params:
 * @fc: flickcurl context
 * @date: A specific date, formatted as YYYY-MM-DD, to return interesting photos for. (or NULL)
 * @list_params: #flickcurl_photos_list_params result parameters (or NULL)
 * 
 * Returns the list of interesting photos for the most recent day or a user-specified date.
 *
 * Optional extra type 'media' that will return an extra media = VALUE
 * for VALUE "photo" or "video".  API addition 2008-04-07.
 *
 * Return value: non-0 on failure
 **/
flickcurl_photos_list*
flickcurl_interestingness_getList_params(flickcurl* fc, const char* date,
                                         flickcurl_photos_list_params* list_params)
{
  flickcurl_photos_list* photos_list = NULL;
  const char* format = NULL;

  flickcurl_init_params(fc);

  /* API parameters */
  if(date) {
    flickcurl_add_param(fc, "date", date);
  }

  /* Photos List parameters */
  flickcurl_append_photos_list_params(fc, list_params, &format);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.interestingness.getList"))
    goto tidy;

  photos_list = flickcurl_invoke_photos_list(fc,
                                             (const xmlChar*)"/rsp/photos",
                                             format);

  tidy:
  if(fc->failed) {
    if(photos_list)
      flickcurl_free_photos_list(photos_list);
    photos_list = NULL;
  }

  return photos_list;
}
Пример #3
0
/**
 * flickcurl_photos_transform_rotate:
 * @fc: flickcurl context
 * @photo_id: The id of the photo to rotate.
 * @degrees: The amount of degrees by which to rotate the photo (clockwise) from it's current orientation. Valid values are 90, 180 and 270.
 * 
 * Rotate a photo.
 *
 * Implements flickr.photos.transform.rotate (0.13)
 * 
 * Return value: non-0 on failure
 **/
int
flickcurl_photos_transform_rotate(flickcurl* fc, const char* photo_id,
                                  int degrees)
{
  xmlDocPtr doc = NULL;
  char degrees_str[4];
  int result = 0;
  
  flickcurl_init_params(fc);

  if(!photo_id || !(degrees == 90 || degrees == 180 || degrees == 270))
    return 1;

  flickcurl_add_param(fc, "photo_id", photo_id);
  sprintf(degrees_str, "%d", degrees);
  flickcurl_add_param(fc, "degrees", degrees_str);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.photos.transform.rotate"))
    goto tidy;

  doc = flickcurl_invoke(fc);
  if(!doc)
    goto tidy;

  result = 0;

  tidy:
  if(fc->failed)
    result = 1;

  return result;
}
Пример #4
0
/**
 * flickcurl_photos_geo_removeLocation:
 * @fc: flickcurl context
 * @photo_id: The id of the photo you want to remove location data from.
 * 
 * Removes the geo data associated with a photo.
 *
 * Implements flickr.photos.geo.removeLocation (0.12)
 * 
 * Return value: non-0 on failure
 **/
int
flickcurl_photos_geo_removeLocation(flickcurl* fc, const char* photo_id)
{
  xmlDocPtr doc = NULL;
  
  flickcurl_init_params(fc, 1);

  if(!photo_id)
    return 1;

  flickcurl_add_param(fc, "photo_id", photo_id);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.photos.geo.removeLocation"))
    goto tidy;

  doc = flickcurl_invoke(fc);
  if(!doc)
    goto tidy;

  tidy:

  return fc->failed;
}
Пример #5
0
/**
 * flickcurl_photosets_orderSets:
 * @fc: flickcurl context
 * @photoset_ids_array: Array of photoset IDs, ordered with the set to show first, first in the list. Any set IDs not given in the list will be set to appear at the end of the list, ordered by their IDs.
 *
 * Set the order of photosets for the calling user.
 *
 * Implements flickr.photosets.orderSets (0.13)
 *
 * Return value: non-0 on failure
 **/
int
flickcurl_photosets_orderSets(flickcurl* fc, const char** photoset_ids_array)
{
    xmlDocPtr doc = NULL;
    int result = 1;
    char* photoset_ids;

    flickcurl_init_params(fc);

    if(!photoset_ids_array)
        return 1;

    photoset_ids = flickcurl_array_join(photoset_ids_array, ',');
    flickcurl_add_param(fc, "photoset_ids", photoset_ids);

    flickcurl_end_params(fc);

    if(flickcurl_prepare(fc, "flickr.photosets.orderSets"))
        goto tidy;

    doc = flickcurl_invoke(fc);
    if(!doc)
        goto tidy;

    result = 0;

tidy:
    if(fc->failed)
        result = 1;
    if(photoset_ids)
        free(photoset_ids);

    return result;
}
Пример #6
0
/**
 * flickcurl_tags_getClusterPhotos:
 * @fc: flickcurl context
 * @tag: The tag that this cluster belongs to.
 * @cluster_id: The top three tags for the cluster, separated by dashes (just like the url).
 * @list_params: #flickcurl_photos_list_params result parameters (or NULL)
 * 
 * Returns the first 24 photos for a given tag cluster
 *
 * Implements flickr.tags.getClusterPhotos (1.7)
 *
 * Added to API (not announced) some time between 2008-09-04 and 2008-09-19
 * 
 * Return value: non-0 on failure
 **/
flickcurl_photos_list*
flickcurl_tags_getClusterPhotos(flickcurl* fc, const char* tag,
                                const char* cluster_id,
                                flickcurl_photos_list_params* list_params)
{
  flickcurl_photos_list* photos_list = NULL;
  const char* format = NULL;
  
  flickcurl_init_params(fc);

  if(!tag || !cluster_id)
    return NULL;

  flickcurl_add_param(fc, "tag", tag);
  flickcurl_add_param(fc, "cluster_id", cluster_id);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.tags.getClusterPhotos"))
    goto tidy;

  photos_list = flickcurl_invoke_photos_list(fc,
                                             (const xmlChar*)"/rsp/photos",
                                             format);
  tidy:
  if(fc->failed) {
    if(photos_list)
      flickcurl_free_photos_list(photos_list);
    photos_list = NULL;
  }

  return photos_list;
}
Пример #7
0
/**
 * flickcurl_photos_notes_add:
 * @fc: flickcurl context
 * @photo_id: The id of the photo to add a note to
 * @note_x: The left coordinate of the note
 * @note_y: The top coordinate of the note
 * @note_w: The width of the note
 * @note_h: The height of the note
 * @note_text: The description of the note
 * 
 * Add a note to a photo.
 *
 * Coordinates and sizes are in pixels, based on the 500px image size
 * shown on individual photo pages.
 *
 * Implements flickr.photos.notes.add (0.12)
 * 
 * Return value: note ID or NULL on failure
 **/
char*
flickcurl_photos_notes_add(flickcurl* fc, const char* photo_id,
                           int note_x, int note_y, int note_w, int note_h,
                           const char* note_text)
{
  xmlDocPtr doc = NULL;
  xmlXPathContextPtr xpathCtx = NULL; 
  char *id = NULL;
  char note_x_s[10];
  char note_y_s[10];
  char note_w_s[10];
  char note_h_s[10];
  
  flickcurl_init_params(fc);

  if(!photo_id || !note_text)
    return NULL;

  flickcurl_add_param(fc, "photo_id", photo_id);
  sprintf(note_x_s, "%d", note_x);
  flickcurl_add_param(fc, "note_x", note_x_s);
  sprintf(note_y_s, "%d", note_y);
  flickcurl_add_param(fc, "note_y", note_y_s);
  sprintf(note_w_s, "%d", note_w);
  flickcurl_add_param(fc, "note_w", note_w_s);
  sprintf(note_h_s, "%d", note_h);
  flickcurl_add_param(fc, "note_h", note_h_s);
  flickcurl_add_param(fc, "note_text", note_text);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.photos.notes.add"))
    goto tidy;

  flickcurl_set_write(fc, 1);
  flickcurl_set_data(fc, (void*)"", 0);

  doc = flickcurl_invoke(fc);
  if(!doc)
    goto tidy;


  xpathCtx = xmlXPathNewContext(doc);
  if(!xpathCtx) {
    flickcurl_error(fc, "Failed to create XPath context for document");
    fc->failed = 1;
    goto tidy;
  }

  id = flickcurl_xpath_eval(fc, xpathCtx, (const xmlChar*)"/rsp/note/@id");

  tidy:
  if(xpathCtx)
    xmlXPathFreeContext(xpathCtx);

  if(fc->failed)
    id = NULL;

  return id;
}
Пример #8
0
/**
 * flickcurl_photos_licenses_setLicense:
 * @fc: flickcurl context
 * @photo_id: The photo to update the license for.
 * @license_id: The license to apply, or 0 (zero) to remove the current license.
 * 
 * Sets the license for a photo.
 *
 * Implements flickr.photos.licenses.setLicense (0.12)
 * 
 * Return value: non-0 on failure
 **/
int
flickcurl_photos_licenses_setLicense(flickcurl* fc, const char* photo_id,
                                     int license_id)
{
  xmlDocPtr doc = NULL;
  int result = 1;
  char license_id_s[5];
  
  flickcurl_init_params(fc, 1);

  if(!photo_id)
    return 1;

  flickcurl_add_param(fc, "photo_id", photo_id);
  sprintf(license_id_s, "%d", license_id);
  flickcurl_add_param(fc, "license_id", license_id_s);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.photos.licenses.setLicense"))
    goto tidy;

  doc = flickcurl_invoke(fc);
  if(!doc)
    goto tidy;

  result = 0;

  tidy:
  if(fc->failed)
    result = 1;

  return result;
}
Пример #9
0
/**
 * flickcurl_photosets_setPrimaryPhoto:
 * @fc: flickcurl context
 * @photoset_id: The id of the photoset to set primary photo to.
 * @photo_id: The id of the photo to set as primary.
 *
 * Set photoset primary photo
 *
 * Implements flickr.photosets.setPrimaryPhoto (1.19)
 *
 * Return value: non-0 on failure
 **/
int
flickcurl_photosets_setPrimaryPhoto(flickcurl* fc, const char* photoset_id,
                                    const char* photo_id)
{
    xmlDocPtr doc = NULL;
    int result = 1;

    flickcurl_init_params(fc);

    if(!photoset_id || !photo_id)
        return 1;

    flickcurl_add_param(fc, "photoset_id", photoset_id);
    flickcurl_add_param(fc, "photo_id", photo_id);

    flickcurl_end_params(fc);

    if(flickcurl_prepare(fc, "flickr.photosets.setPrimaryPhoto"))
        goto tidy;

    flickcurl_set_write(fc, 1);
    flickcurl_set_data(fc, (void*)"", 0);

    doc = flickcurl_invoke(fc);
    if(!doc)
        goto tidy;

    result = 0;

tidy:
    if(fc->failed)
        result = 1;

    return result;
}
Пример #10
0
/**
 * flickcurl_people_getPhotosOf_params:
 * @fc: flickcurl context
 * @user_id: The NSID of the user who's photo to search. A value of "me" will search against the calling user's photos for authenticated calls.
 * @list_params: #flickcurl_photos_list_params result parameters (or NULL)
 * 
 * Returns a list of photos containing a particular Flickr member.
 *
 * Announced 2010-01-21
 * http://code.flickr.com/blog/2010/01/21/people-in-photos-the-api-methods/
 * 
 * Return value: photos list or NULL on failure
 **/
flickcurl_photos_list*
flickcurl_people_getPhotosOf_params(flickcurl* fc, const char* user_id,
                                    flickcurl_photos_list_params* list_params)
{
  flickcurl_photos_list* photos_list = NULL;
  const char* format = NULL;
  
  flickcurl_init_params(fc, 0);

  if(!user_id)
    return photos_list;

  flickcurl_add_param(fc, "user_id", user_id);

  /* Photos List parameters */
  flickcurl_append_photos_list_params(fc, list_params, &format);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.people.getPhotosOf"))
    goto tidy;

  photos_list = flickcurl_invoke_photos_list(fc,
                                             (const xmlChar*)"/rsp/photos",
                                             format);

  tidy:
  if(fc->failed) {
    if(photos_list)
      flickcurl_free_photos_list(photos_list);
    photos_list = NULL;
  }

  return photos_list;
}
Пример #11
0
/**
 * flickcurl_photos_notes_delete:
 * @fc: flickcurl context
 * @note_id: The id of the note to delete
 * 
 * Delete a note from a photo.
 *
 * Implements flickr.photos.notes.delete (0.12)
 * 
 * Return value: non-0 on failure
 **/
int
flickcurl_photos_notes_delete(flickcurl* fc, const char* note_id)
{
  xmlDocPtr doc = NULL;
  int result = 1;
  
  flickcurl_init_params(fc);

  if(!note_id)
    return 1;

  flickcurl_add_param(fc, "note_id", note_id);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.photos.notes.delete"))
    goto tidy;

  flickcurl_set_write(fc, 1);
  flickcurl_set_data(fc, (void*)"", 0);

  doc = flickcurl_invoke(fc);
  if(!doc)
    goto tidy;

  result = 0;

  tidy:
  if(fc->failed)
    result = 1;

  return result;
}
Пример #12
0
/**
 * flickcurl_photosets_delete:
 * @fc: flickcurl context
 * @photoset_id: The id of the photoset to delete. Must be owned by the calling user.
 *
 * Delete a photoset.
 *
 * Implements flickr.photosets.delete (0.13)
 *
 * Return value: non-0 on failure
 **/
int
flickcurl_photosets_delete(flickcurl* fc, const char* photoset_id)
{
    xmlDocPtr doc = NULL;

    flickcurl_init_params(fc);

    if(!photoset_id)
        return 1;

    flickcurl_add_param(fc, "photoset_id", photoset_id);

    flickcurl_end_params(fc);

    if(flickcurl_prepare(fc, "flickr.photosets.delete"))
        goto tidy;

    flickcurl_set_write(fc, 1);
    flickcurl_set_data(fc, (void*)"", 0);

    doc = flickcurl_invoke(fc);
    if(!doc)
        goto tidy;

tidy:

    return fc->failed;
}
Пример #13
0
/**
 * flickcurl_groups_pools_add:
 * @fc: flickcurl context
 * @photo_id: The id of the photo to add to the group pool.
 * @group_id: The NSID of the group who's pool the photo is to be added to.
 * 
 * Add a photo to a group's pool.
 *
 * Implements flickr.groups.pools.add (0.12)
 * 
 * Return value: non-0 on failure
 **/
int
flickcurl_groups_pools_add(flickcurl* fc, const char* photo_id,
                           const char* group_id)
{
  xmlDocPtr doc = NULL;
  int result = 1;
  
  flickcurl_init_params(fc);

  if(!photo_id || !group_id)
    return 1;

  flickcurl_add_param(fc, "photo_id", photo_id);
  flickcurl_add_param(fc, "group_id", group_id);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.groups.pools.add"))
    goto tidy;

  flickcurl_set_write(fc, 1);
  flickcurl_set_data(fc, (void*)"", 0);

  doc = flickcurl_invoke(fc);
  if(!doc)
    goto tidy;

  result = 0;

  tidy:
  if(fc->failed)
    result = 1;

  return result;
}
Пример #14
0
/**
 * flickcurl_photos_geo_batchCorrectLocation:
 * @fc: flickcurl context
 * @location: The location (lat, long, accuracy) of the photos to update.
 * @place_id: A Flickr Places ID (or NULL)
 * @woe_id: A Where On Earth (WOE) ID (or 0)
 *
 * Correct the places hierarchy for all the photos for a user at a
 * given location (latitude, longitude and accuracy).
 *
 * You must pass either a valid Places ID in @place_id or a WOE ID in
 * @woe_id.
 * 
 * Batch corrections are processed in a delayed queue so it may take
 * a few minutes before the changes are reflected in a user's photos.
 *
 * Implements flickr.photos.geo.batchCorrectLocation (1.8)
 * 
 * Return value: non-0 on failure
 **/
int
flickcurl_photos_geo_batchCorrectLocation(flickcurl* fc,
                                          flickcurl_location* location,
                                          const char* place_id, int woe_id)
{
  xmlDocPtr doc = NULL;
  char latitude_s[50];
  char longitude_s[50];
  char accuracy_s[50];
  char woe_id_str[10];
  int result = 0;

  flickcurl_init_params(fc, 1);

  if(!place_id || !woe_id)
    return 1;

  if(location->latitude < -90.0)
    location->latitude= -90.0;
  if(location->latitude > 90.0)
    location->latitude= 90.0;
  if(location->longitude < -180.0)
    location->longitude= -180.0;
  if(location->longitude > 180.0)
    location->longitude= 180.0;
  if(location->accuracy < 1 || location->accuracy > 16)
    location->accuracy = 0;
  

  sprintf(latitude_s, "%f", location->latitude);
  flickcurl_add_param(fc, "lat", latitude_s);
  sprintf(longitude_s, "%f", location->longitude);
  flickcurl_add_param(fc, "lon", longitude_s);
  sprintf(accuracy_s, "%d", location->accuracy);
  flickcurl_add_param(fc, "accuracy", accuracy_s);
  if(place_id) {
    flickcurl_add_param(fc, "place_id", place_id);
  }
  if(woe_id > 0) {
    sprintf(woe_id_str, "%d", woe_id);
    flickcurl_add_param(fc, "woe_id", woe_id_str);
  }
  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.photos.geo.batchCorrectLocation"))
    goto tidy;

  doc = flickcurl_invoke(fc);
  if(!doc)
    goto tidy;

  result = 0;

  tidy:
  if(fc->failed)
    result = 1;

  return result;
}
Пример #15
0
/**
 * flickcurl_photos_people_editCoords:
 * @fc: flickcurl context
 * @photo_id: The id of the photo to edit a person in.
 * @user_id: The NSID of the person to edit in a photo.
 * @person_x: The left-most pixel co-ordinate of the box around the person.
 * @person_y: The top-most pixel co-ordinate of the box around the person.
 * @person_w: The width (in pixels) of the box around the person.
 * @person_h: The height (in pixels) of the box around the person.
 * 
 * Edit the bounding box of an existing person on a photo.
 *
 * Implements flickr.photos.people.editCoords (1.17)
 * 
 * Announced 2010-01-21
 * http://code.flickr.com/blog/2010/01/21/people-in-photos-the-api-methods/
 *
 * Return value: non-0 on failure
 **/
int
flickcurl_photos_people_editCoords(flickcurl* fc, const char* photo_id,
                                   const char* user_id,
                                   int person_x, int person_y,
                                   int person_w, int person_h)
{
  xmlDocPtr doc = NULL;
  xmlXPathContextPtr xpathCtx = NULL; 
  int rc = 0;
  char person_x_str[10];
  char person_y_str[10];
  char person_w_str[10];
  char person_h_str[10];
  
  flickcurl_init_params(fc, 1);

  if(!photo_id || !user_id || 
     person_x < 0  || person_y < 0 || person_w <0 || person_h < 0)
    return 1;

  flickcurl_add_param(fc, "photo_id", photo_id);
  flickcurl_add_param(fc, "user_id", user_id);

  sprintf(person_x_str, "%d", person_x);
  flickcurl_add_param(fc, "person_x", person_x_str);
  sprintf(person_y_str, "%d", person_y);
  flickcurl_add_param(fc, "person_y", person_y_str);
  sprintf(person_w_str, "%d", person_w);
  flickcurl_add_param(fc, "person_w", person_w_str);
  sprintf(person_h_str, "%d", person_h);
  flickcurl_add_param(fc, "person_h", person_h_str);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.photos.people.editCoords"))
    goto tidy;

  doc = flickcurl_invoke(fc);
  if(!doc)
    goto tidy;


  xpathCtx = xmlXPathNewContext(doc);
  if(!xpathCtx) {
    flickcurl_error(fc, "Failed to create XPath context for document");
    fc->failed = 1;
    goto tidy;
  }

  tidy:
  if(xpathCtx)
    xmlXPathFreeContext(xpathCtx);

  if(fc->failed)
    rc = 1;

  return rc;
}
Пример #16
0
/**
 * flickcurl_galleries_create:
 * @fc: flickcurl context
 * @title: The name of the gallery
 * @description: A short description for the gallery
 * @primary_photo_id: The first photo to add to your gallery (or NULL)
 * @gallery_url_p: pointer to variable to store new gallery URL (or NULL)
 *
 * Create a new gallery for the calling user.
 *
 * Implements flickr.galleries.create (1.18)
 *
 * Announced 2010-04-08
 * http://code.flickr.com/blog/2010/04/08/galleries-apis/
 *
 * Return value: gallery ID or NULL on failure
 **/
char*
flickcurl_galleries_create(flickcurl* fc,
                           const char* title,
                           const char* description,
                           const char* primary_photo_id,
                           char** gallery_url_p)
{
    xmlDocPtr doc = NULL;
    xmlXPathContextPtr xpathCtx = NULL;
    char* gallery_id = NULL;

    flickcurl_init_params(fc);

    if(!title || !description)
        return NULL;

    flickcurl_add_param(fc, "title", title);
    flickcurl_add_param(fc, "description", description);
    if(primary_photo_id) {
        flickcurl_add_param(fc, "primary_photo_id", primary_photo_id);
    }

    flickcurl_end_params(fc);

    if(flickcurl_prepare(fc, "flickr.galleries.create"))
        goto tidy;

    flickcurl_set_write(fc, 1);
    flickcurl_set_data(fc, (void*)"", 0);

    doc = flickcurl_invoke(fc);
    if(!doc)
        goto tidy;

    xpathCtx = xmlXPathNewContext(doc);
    if(!xpathCtx) {
        flickcurl_error(fc, "Failed to create XPath context for document");
        fc->failed = 1;
        goto tidy;
    }

    gallery_id = flickcurl_xpath_eval(fc, xpathCtx,
                                      (const xmlChar*)"/rsp/gallery/@id");
    if(gallery_url_p) {
        *gallery_url_p = flickcurl_xpath_eval(fc, xpathCtx,
                                              (const xmlChar*)"/rsp/gallery/@url");
    }

tidy:
    if(xpathCtx)
        xmlXPathFreeContext(xpathCtx);

    if(fc->failed)
        gallery_id = NULL;

    return gallery_id;
}
Пример #17
0
/**
 * flickcurl_photos_geo_photosForLocation_params:
 * @fc: flickcurl context
 * @location: The location (lat, long, accuracy) of the photos
 * @list_params: #flickcurl_photos_list_params result parameters (or NULL)
 * 
 * Get a list of photos for a user at a specific location (latitude, longitude
 * and accuracy)
 *
 * Return value: list of photos or NULL on failure
 **/
flickcurl_photos_list*
flickcurl_photos_geo_photosForLocation_params(flickcurl* fc,
                                              flickcurl_location* location,
                                              flickcurl_photos_list_params* list_params)
{
  flickcurl_photos_list* photos_list = NULL;
  char latitude_s[50];
  char longitude_s[50];
  char accuracy_s[50];
  const char* format = NULL;

  flickcurl_init_params(fc, 0);

  if(!location)
    return NULL;
  
  if(location->latitude < -90.0)
    location->latitude= -90.0;
  if(location->latitude > 90.0)
    location->latitude= 90.0;
  if(location->longitude < -180.0)
    location->longitude= -180.0;
  if(location->longitude > 180.0)
    location->longitude= 180.0;
  if(location->accuracy < 1 || location->accuracy > 16)
    location->accuracy = 0;
  

  sprintf(latitude_s, "%f", location->latitude);
  flickcurl_add_param(fc, "lat", latitude_s);
  sprintf(longitude_s, "%f", location->longitude);
  flickcurl_add_param(fc, "lon", longitude_s);
  sprintf(accuracy_s, "%d", location->accuracy);
  flickcurl_add_param(fc, "accuracy", accuracy_s);

  /* Photos List parameters */
  flickcurl_append_photos_list_params(fc, list_params, &format);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.photos.geo.photosForLocation"))
    goto tidy;

  photos_list = flickcurl_invoke_photos_list(fc,
                                             (const xmlChar*)"/rsp/photos",
                                             format);

  tidy:
  if(fc->failed) {
    if(photos_list)
      flickcurl_free_photos_list(photos_list);
    photos_list = NULL;
  }

  return photos_list;
}
Пример #18
0
/**
 * flickcurl_photos_geo_setLocation:
 * @fc: flickcurl context
 * @photo_id: The id of the photo to set location data for.
 * @location: The location
 * 
 * Sets the geo data (latitude and longitude and, optionally, the
 * accuracy level) for a photo.
 *
 * Implements flickr.photos.geo.setLocation (0.12)
 * 
 * Return value: non-0 on failure
 **/
int
flickcurl_photos_geo_setLocation(flickcurl* fc, const char* photo_id,
                                 flickcurl_location* location)
{
  xmlDocPtr doc = NULL;
  char latitude_s[50];
  char longitude_s[50];
  char accuracy_s[50];
  int result = 1;
  
  flickcurl_init_params(fc, 1);

  if(!photo_id)
    return 1;

  if(location->latitude < -90.0)
    location->latitude= -90.0;
  if(location->latitude > 90.0)
    location->latitude= 90.0;
  if(location->longitude < -180.0)
    location->longitude= -180.0;
  if(location->longitude > 180.0)
    location->longitude= 180.0;
  if(location->accuracy < 1 || location->accuracy > 16)
    location->accuracy = 0;
  

  flickcurl_add_param(fc, "photo_id", photo_id);
  sprintf(latitude_s, "%f", location->latitude);
  flickcurl_add_param(fc, "lat", latitude_s);
  sprintf(longitude_s, "%f", location->longitude);
  flickcurl_add_param(fc, "lon", longitude_s);
  if(location->accuracy >= 1) {
    sprintf(accuracy_s, "%d", location->accuracy);
    flickcurl_add_param(fc, "accuracy", accuracy_s);
  }

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.photos.geo.setLocation"))
    goto tidy;

  doc = flickcurl_invoke(fc);
  if(!doc)
    goto tidy;

  result = 0;

  tidy:
  if(fc->failed)
    result = 1;

  return result;
}
Пример #19
0
/**
 * flickcurl_collections_getTree:
 * @fc: flickcurl context
 * @collection_id: The ID of the collection to fetch a tree for, or zero to fetch the root collection. Defaults to zero. (or NULL)
 * @user_id: The ID of the account to fetch the collection tree for. Deafults to the calling user. (or NULL)
 * 
 * Returns a tree (or sub tree) of collections belonging to a given user.
 *
 * Implements flickr.collections.getTree (1.12)
 * 
 * Return value: a collection or NULL on failure
 **/
flickcurl_collection*
flickcurl_collections_getTree(flickcurl* fc, const char* collection_id,
                              const char* user_id)
{
  xmlDocPtr doc = NULL;
  xmlXPathContextPtr xpathCtx = NULL; 
  flickcurl_collection* collection  =  NULL;
  
  flickcurl_init_params(fc, 0);

  if(collection_id) {
    flickcurl_add_param(fc, "collection_id", collection_id);
  }
  if(user_id) {
    flickcurl_add_param(fc, "user_id", user_id);
  }

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.collections.getTree"))
    goto tidy;

  doc = flickcurl_invoke(fc);
  if(!doc)
    goto tidy;


  xpathCtx = xmlXPathNewContext(doc);
  if(!xpathCtx) {
    flickcurl_error(fc, "Failed to create XPath context for document");
    fc->failed = 1;
    goto tidy;
  }

  collection = flickcurl_build_collection(fc, xpathCtx,
                                          (const xmlChar*)"/rsp/collections/collection");

  tidy:
  if(xpathCtx)
    xmlXPathFreeContext(xpathCtx);

  if(fc->failed) {
    if(collection)
      flickcurl_free_collection(collection);

    collection = NULL;
  }

  return collection;
}
Пример #20
0
/**
 * flickcurl_galleries_getInfo:
 * @fc: flickcurl context
 * @gallery_id: The gallery ID you are requesting information for.
 *
 * Get information for a gallery.
 *
 * Implements flickr.galleries.getInfo (1.18)
 *
 * Announced 2010-04-08
 * http://code.flickr.com/blog/2010/04/08/galleries-apis/
 *
 * Return value: gallery or NULL on failure
 **/
flickcurl_gallery*
flickcurl_galleries_getInfo(flickcurl* fc, const char* gallery_id)
{
    xmlDocPtr doc = NULL;
    xmlXPathContextPtr xpathCtx = NULL;
    flickcurl_gallery* gallery = NULL;
    flickcurl_gallery** galleries = NULL;

    flickcurl_init_params(fc);

    if(!gallery_id)
        return NULL;

    flickcurl_add_param(fc, "gallery_id", gallery_id);

    flickcurl_end_params(fc);

    if(flickcurl_prepare(fc, "flickr.galleries.getInfo"))
        goto tidy;

    doc = flickcurl_invoke(fc);
    if(!doc)
        goto tidy;


    xpathCtx = xmlXPathNewContext(doc);
    if(!xpathCtx) {
        flickcurl_error(fc, "Failed to create XPath context for document");
        fc->failed = 1;
        goto tidy;
    }

    galleries = flickcurl_build_galleries(fc, xpathCtx,
                                          (const xmlChar*)"/rsp/galleries/gallery",
                                          NULL);
    if(galleries) {
        gallery = galleries[0];
        galleries[0] = NULL;
        flickcurl_free_galleries(galleries);
    }

tidy:
    if(xpathCtx)
        xmlXPathFreeContext(xpathCtx);

    if(fc->failed)
        gallery = NULL;

    return gallery;
}
Пример #21
0
/**
 * flickcurl_galleries_addPhoto:
 * @fc: flickcurl context
 * @gallery_id: The ID of the gallery to add a photo to as returned by flickcurl_galleries_getList() and flickcurl_galleries_getListForPhoto().
 * @photo_id: The photo ID to add to the gallery.
 * @comment_text: A short comment or story to accompany the photo (or NULL).
 *
 * Add a photo to a gallery.
 *
 * Implements flickr.galleries.addPhoto (1.17)
 *
 * Return value: non-0 on failure
 **/
int
flickcurl_galleries_addPhoto(flickcurl* fc, const char* gallery_id,
                             const char* photo_id, const char* comment_text)
{
    xmlDocPtr doc = NULL;
    xmlXPathContextPtr xpathCtx = NULL;
    void* result = NULL;

    flickcurl_init_params(fc);

    if(!gallery_id || !photo_id)
        return 1;

    flickcurl_add_param(fc, "gallery_id", gallery_id);
    flickcurl_add_param(fc, "photo_id", photo_id);
    if(comment_text) {
        flickcurl_add_param(fc, "comment", comment_text);
    }

    flickcurl_end_params(fc);

    if(flickcurl_prepare(fc, "flickr.galleries.addPhoto"))
        goto tidy;

    flickcurl_set_write(fc, 1);
    flickcurl_set_data(fc, (void*)"", 0);

    doc = flickcurl_invoke(fc);
    if(!doc)
        goto tidy;


    xpathCtx = xmlXPathNewContext(doc);
    if(!xpathCtx) {
        flickcurl_error(fc, "Failed to create XPath context for document");
        fc->failed = 1;
        goto tidy;
    }

    result = NULL; /* your code here */

tidy:
    if(xpathCtx)
        xmlXPathFreeContext(xpathCtx);

    if(fc->failed)
        result = NULL;

    return (result == NULL);
}
Пример #22
0
/**
 * flickcurl_photos_notes_edit:
 * @fc: flickcurl context
 * @note_id: The id of the note to edit
 * @note_x: The left coordinate of the note
 * @note_y: The top coordinate of the note
 * @note_w: The width of the note
 * @note_h: The height of the note
 * @note_text: The description of the note
 * 
 * Edit a note on a photo. Coordinates and sizes are in pixels, based on the 500px image size shown on individual photo pages.

 *
 * Implements flickr.photos.notes.edit (0.12)
 * 
 * Return value: non-0 on failure
 **/
int
flickcurl_photos_notes_edit(flickcurl* fc,
                            const char* note_id,
                            int note_x, int note_y, int note_w, int note_h,
                            const char* note_text)
{
  xmlDocPtr doc = NULL;
  int result = 1;
  char note_x_s[10];
  char note_y_s[10];
  char note_w_s[10];
  char note_h_s[10];
  
  flickcurl_init_params(fc);

  if(!note_id || !note_text)
    return 1;

  flickcurl_add_param(fc, "note_id", note_id);
  sprintf(note_x_s, "%d", note_x);
  flickcurl_add_param(fc, "note_x", note_x_s);
  sprintf(note_y_s, "%d", note_y);
  flickcurl_add_param(fc, "note_y", note_y_s);
  sprintf(note_w_s, "%d", note_w);
  flickcurl_add_param(fc, "note_w", note_w_s);
  sprintf(note_h_s, "%d", note_h);
  flickcurl_add_param(fc, "note_h", note_h_s);
  flickcurl_add_param(fc, "note_text", note_text);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.photos.notes.edit"))
    goto tidy;

  flickcurl_set_write(fc, 1);
  flickcurl_set_data(fc, (void*)"", 0);

  doc = flickcurl_invoke(fc);
  if(!doc)
    goto tidy;

  result = 0;

  tidy:
  if(fc->failed)
    result = 1;

  return result;
}
Пример #23
0
/**
 * flickcurl_photos_geo_correctLocation:
 * @fc: flickcurl context
 * @photo_id: The ID of the photo whose WOE location is being corrected.
 * @place_id: A Flickr Places ID (or NULL)
 * @woe_id: A Where On Earth (WOE) ID (or NULL)
 * 
 * Correct a photo location.
 *
 * You must pass either a valid Places ID in @place_id or a WOE ID in @woe_id.
 * 
 * Implements flickr.photos.geo.correctLocation (1.8)
 * 
 * Return value: non-0 on failure
 **/
int
flickcurl_photos_geo_correctLocation(flickcurl* fc, const char* photo_id,
                                     const char* place_id, int woe_id)
{
  xmlDocPtr doc = NULL;
  xmlXPathContextPtr xpathCtx = NULL; 
  void* result = NULL;
  char woe_id_str[10];
  
  flickcurl_init_params(fc, 0);

  if(!photo_id)
    return 1;

  flickcurl_add_param(fc, "photo_id", photo_id);
  flickcurl_add_param(fc, "place_id", place_id);
  if(woe_id > 0) {
    sprintf(woe_id_str, "%d", woe_id);
    flickcurl_add_param(fc, "woe_id", woe_id_str);
  }
  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.photos.geo.correctLocation"))
    goto tidy;

  doc = flickcurl_invoke(fc);
  if(!doc)
    goto tidy;


  xpathCtx = xmlXPathNewContext(doc);
  if(!xpathCtx) {
    flickcurl_error(fc, "Failed to create XPath context for document");
    fc->failed = 1;
    goto tidy;
  }

  result = NULL; /* your code here */

  tidy:
  if(xpathCtx)
    xmlXPathFreeContext(xpathCtx);

  if(fc->failed)
    result = NULL;

  return (result == NULL);
}
Пример #24
0
/**
 * flickcurl_photos_geo_setContext:
 * @fc: flickcurl context
 * @photo_id: The id of the photo to set context data for.
 * @context: Context is a numeric value representing the photo's geotagginess beyond latitude and longitude. The current values are: 0: not defined, 1: indoors, 2: outdoors.
 * 
 * Indicate the state of a photo's geotagginess beyond latitude and longitude.
 * 
 * Note : photos passed to this method must already be geotagged
 * using the flickcurl_photos_geo_setLocation() method.
 *
 * Implements flickr.photos.geo.setContext (1.8)
 * 
 * Return value: non-0 on failure
 **/
int
flickcurl_photos_geo_setContext(flickcurl* fc, const char* photo_id,
                                int context)
{
  xmlDocPtr doc = NULL;
  xmlXPathContextPtr xpathCtx = NULL; 
  char context_str[3];
  void* result = NULL;
  
  flickcurl_init_params(fc, 1);

  if(!photo_id || context < 0 || context > 2)
    return 1;

  flickcurl_add_param(fc, "photo_id", photo_id);
  sprintf(context_str, "%d", context);
  flickcurl_add_param(fc, "context", context_str);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.photos.geo.setContext"))
    goto tidy;

  doc = flickcurl_invoke(fc);
  if(!doc)
    goto tidy;


  xpathCtx = xmlXPathNewContext(doc);
  if(!xpathCtx) {
    flickcurl_error(fc, "Failed to create XPath context for document");
    fc->failed = 1;
    goto tidy;
  }

  result = NULL; /* your code here */

  tidy:
  if(xpathCtx)
    xmlXPathFreeContext(xpathCtx);

  if(fc->failed)
    result = NULL;

  return (result == NULL);
}
Пример #25
0
/**
 * flickcurl_photos_geo_getPerms:
 * @fc: flickcurl context
 * @photo_id: The id of the photo to get permissions for.
 * 
 * Get permissions for who may view geo data for a photo.
 *
 * Implements flickr.photos.geo.getPerms (0.12)
 * 
 * Return value: non-0 on failure
 **/
flickcurl_perms*
flickcurl_photos_geo_getPerms(flickcurl* fc, const char* photo_id)
{
  xmlDocPtr doc = NULL;
  xmlXPathContextPtr xpathCtx = NULL; 
  flickcurl_perms* perms = NULL;
  
  flickcurl_init_params(fc, 0);

  if(!photo_id)
    return NULL;

  flickcurl_add_param(fc, "photo_id", photo_id);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.photos.geo.getPerms"))
    goto tidy;

  doc = flickcurl_invoke(fc);
  if(!doc)
    goto tidy;


  xpathCtx = xmlXPathNewContext(doc);
  if(!xpathCtx) {
    flickcurl_error(fc, "Failed to create XPath context for document");
    fc->failed = 1;
    goto tidy;
  }

  perms = flickcurl_build_perms(fc, xpathCtx,
                              (const xmlChar*)"/rsp/perms");

  tidy:
  if(xpathCtx)
    xmlXPathFreeContext(xpathCtx);

  if(fc->failed) {
    if(perms)
      flickcurl_free_perms(perms);
    perms = NULL;
  }

  return perms;
}
Пример #26
0
/**
 * flickcurl_photosets_comments_addComment:
 * @fc: flickcurl context
 * @photoset_id: The id of the photoset to add a comment to.
 * @comment_text: Text of the comment
 * 
 * Add a comment to a photoset.
 *
 * Implements flickr.photosets.comments.addComment (0.10)
 * 
 * Return value: new comment ID or non-NULL on failure
 **/
char*
flickcurl_photosets_comments_addComment(flickcurl* fc,
                                        const char* photoset_id,
                                        const char* comment_text)
{
  xmlDocPtr doc = NULL;
  xmlXPathContextPtr xpathCtx = NULL; 
  char* id = NULL;
  
  flickcurl_init_params(fc, 1);

  if(!photoset_id || !comment_text)
    return NULL;

  flickcurl_add_param(fc, "photoset_id", photoset_id);
  flickcurl_add_param(fc, "comment_text", comment_text);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.photosets.comments.addComment"))
    goto tidy;

  doc = flickcurl_invoke(fc);
  if(!doc)
    goto tidy;


  xpathCtx = xmlXPathNewContext(doc);
  if(!xpathCtx) {
    flickcurl_error(fc, "Failed to create XPath context for document");
    fc->failed = 1;
    goto tidy;
  }

  id = flickcurl_xpath_eval(fc, xpathCtx, (const xmlChar*)"/rsp/comment/@id");

  tidy:
  if(xpathCtx)
    xmlXPathFreeContext(xpathCtx);

  if(fc->failed)
    id = NULL;

  return id;
}
Пример #27
0
/**
 * flickcurl_blogs_postPhoto:
 * @fc: flickcurl context
 * @blog_id: The id of the blog to post to
 * @photo_id: The id of the photo to blog
 * @title: The blog post title
 * @description: The blog post body
 * @blog_password: The password for the blog (used when the blog does not have a stored password) (or NULL)
 *
 * Post a photo to a blog/
 *
 * Implements flickr.blogs.postPhoto (1.0)
 * 
 * Return value: non-0 on failure
 **/
int
flickcurl_blogs_postPhoto(flickcurl* fc, const char* blog_id,
                          const char* photo_id, const char* title,
                          const char* description, const char* blog_password)
{
  xmlDocPtr doc = NULL;
  xmlXPathContextPtr xpathCtx = NULL; 
  
  flickcurl_init_params(fc, 0);

  if(!blog_id || !photo_id || !title || !description)
    return 1;

  flickcurl_add_param(fc, "blog_id", blog_id);
  flickcurl_add_param(fc, "photo_id", photo_id);
  flickcurl_add_param(fc, "title", title);
  flickcurl_add_param(fc, "description", description);
  if(blog_password) {
    flickcurl_add_param(fc, "blog_password", blog_password);
  }

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.blogs.postPhoto"))
    goto tidy;

  doc = flickcurl_invoke(fc);
  if(!doc)
    goto tidy;


  xpathCtx = xmlXPathNewContext(doc);
  if(!xpathCtx) {
    flickcurl_error(fc, "Failed to create XPath context for document");
    fc->failed = 1;
    goto tidy;
  }

  tidy:
  if(xpathCtx)
    xmlXPathFreeContext(xpathCtx);

  return fc->failed;
}
Пример #28
0
/**
 * flickcurl_prefs_getPrivacy:
 * @fc: flickcurl context
 * 
 * Returns the default privacy level preference for the user.
 * 
 * Possible values are: Public (1), Friends only (2),  Family only (3)
 * Friends and Family (4) and Private (5)
 *
 * Implements flickr.prefs.getPrivacy (1.3)
 * 
 * Return value: privacy level or <0 on failure
 **/
int
flickcurl_prefs_getPrivacy(flickcurl* fc)
{
  xmlDocPtr doc = NULL;
  xmlXPathContextPtr xpathCtx = NULL; 
  char* privacy_level_str= NULL;
  int privacy_level= -1;
  
  flickcurl_init_params(fc, 0);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.prefs.getPrivacy"))
    goto tidy;

  doc = flickcurl_invoke(fc);
  if(!doc)
    goto tidy;


  xpathCtx = xmlXPathNewContext(doc);
  if(!xpathCtx) {
    flickcurl_error(fc, "Failed to create XPath context for document");
    fc->failed = 1;
    goto tidy;
  }

  privacy_level_str = flickcurl_xpath_eval(fc, xpathCtx,
                                           (const xmlChar*)"/rsp/person/@privacy");
  if(privacy_level_str) {
    privacy_level = atoi(privacy_level_str);
    free(privacy_level_str);
  }


  tidy:
  if(xpathCtx)
    xmlXPathFreeContext(xpathCtx);

  if(fc->failed)
    privacy_level= -1;

  return privacy_level;
}
Пример #29
0
/**
 * flickcurl_galleries_editPhotos:
 * @fc: flickcurl context
 * @gallery_id: The id of the gallery to modify. The gallery must belong to the calling user.
 * @primary_photo_id: The id of the photo to use as the 'primary' photo for the gallery. This id must also be passed along in photo_ids list argument.
 * @photo_ids_array: Array of photo ids to include in the gallery. They will appear in the set in the order sent. This list MUST contain the primary photo id. This list of photos replaces the existing list.
 *
 * Modify the photos in a gallery. Use this method to add, remove and re-order photos.
 *
 * Implements flickr.galleries.editPhotos (1.18)
 *
 * Announced 2010-04-08
 * http://code.flickr.com/blog/2010/04/08/galleries-apis/
 *
 * Return value: non-0 on failure
 **/
int
flickcurl_galleries_editPhotos(flickcurl* fc, const char* gallery_id,
                               const char* primary_photo_id,
                               const char** photo_ids_array)
{
    xmlDocPtr doc = NULL;
    int result = 1;
    char* photo_ids = NULL;

    flickcurl_init_params(fc);

    if(!gallery_id || !primary_photo_id || !photo_ids_array)
        return 1;

    flickcurl_add_param(fc, "gallery_id", gallery_id);
    flickcurl_add_param(fc, "primary_photo_id", primary_photo_id);
    photo_ids = flickcurl_array_join(photo_ids_array, ',');
    flickcurl_add_param(fc, "photo_ids", photo_ids);

    flickcurl_end_params(fc);

    if(flickcurl_prepare(fc, "flickr.galleries.editPhotos"))
        goto tidy;

    flickcurl_set_write(fc, 1);
    flickcurl_set_data(fc, (void*)"", 0);

    doc = flickcurl_invoke(fc);
    if(!doc)
        goto tidy;


    result = 0;

tidy:
    if(photo_ids)
        free(photo_ids);

    if(fc->failed)
        result = 1;

    return result;
}
Пример #30
0
/**
 * flickcurl_prefs_getContentType:
 * @fc: flickcurl context
 * 
 * Returns the default content type preference for the user.
 *
 * Implements flickr.prefs.getContentType (1.3)
 * 
 * Return value: content type or <0 on failure
 **/
int
flickcurl_prefs_getContentType(flickcurl* fc)
{
  xmlDocPtr doc = NULL;
  xmlXPathContextPtr xpathCtx = NULL; 
  char* content_type_str = NULL;
  int content_type= -1;
  
  flickcurl_init_params(fc, 0);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.prefs.getContentType"))
    goto tidy;

  doc = flickcurl_invoke(fc);
  if(!doc)
    goto tidy;


  xpathCtx = xmlXPathNewContext(doc);
  if(!xpathCtx) {
    flickcurl_error(fc, "Failed to create XPath context for document");
    fc->failed = 1;
    goto tidy;
  }
  
  content_type_str = flickcurl_xpath_eval(fc, xpathCtx,
                                          (const xmlChar*)"/rsp/person/@content_type");
  if(content_type_str) {
    content_type = atoi(content_type_str);
    free(content_type_str);
  }
  
  tidy:
  if(xpathCtx)
    xmlXPathFreeContext(xpathCtx);

  if(fc->failed)
    content_type= -1;

  return content_type;
}