Example #1
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;
}
Example #2
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)
{
  const char* parameters[9][2];
  int count = 0;
  xmlDocPtr doc = NULL;
  xmlXPathContextPtr xpathCtx = NULL; 
  flickcurl_collection* collection  =  NULL;
  
  if(collection_id) {
    parameters[count][0]  = "collection_id";
    parameters[count++][1]= collection_id;
  }
  if(user_id) {
    parameters[count][0]  = "user_id";
    parameters[count++][1]= user_id;
  }

  parameters[count][0]  = NULL;

  if(flickcurl_prepare(fc, "flickr.collections.getTree", parameters, count))
    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)
    collection = NULL;

  return collection;
}