This distribution provides a means for generating authentication URLs for and invoking methods of the Remember The Milk API.
It utilizes glib2, curl and openssl and thus is probably most useful for *NIX applications — but re-implementation for Win32 is probably not too difficult.
At present, these bindings only provide a means of invocation — your application must process the responses it receives (usually XML) manually (with expat, libxml2, etc.)
The C bindings for the Remember The Milk API are BSD licensed.
Version 0 - Released 2006-05-12 - Initial proof of concept release.
To initialize the bindings, call:
rtm_api *rtm = rtm_api_init(YOUR_API_KEY, YOUR_API_SECRET);
Conversely, invoking:
rtm_api_free(rtm);
Frees all resources allocated by the binding.
To generate an authentication URL, simply call:
char *url = rtm_api_auth_get_url(rtm, "write", NULL);
This will generate an authentication URL requesting write
permissions. Valid permission values are read
, write
and delete
.
The third parameter is a frob
value, which should be used as described in User Authentication. We could retrieve a frob
value with:
char *response = rtm_api_call_method(rtm, "rtm.auth.getFrob");
response
will contain a XML response with a frob
value as described in rtm.auth.getFrob.
We can exchange the frob
for an auth_token
by calling:
rtm_api_param_add(rtm, "frob", frob); char *response = rtm_api_call_method(rtm, "rtm.auth.getToken");
response
will contain a XML response with a token
value as described in rtm.auth.getToken.
Using the token
value, we can now make authenticated API calls. For Example:
rtm_api_set_auth_token(rtm, auth_token); char *response = rtm_api_call_authenticated_method(rtm, "rtm.tasks.getList");
Would retrieve all our tasks as per rtm.tasks.getList and store the result in response
.
rtm_api_set_timeline
should be used to set a timeline for utilizing the API as per Timelines.
Two additional rtm_api_param_add_*
functions are provided:
rtm_api_param_add_long
- Works the same way as rtm_api_param_add
, but the last argument must be of type long
.rtm_api_param_add_date
- Works the same way as rtm_api_param_add
, but the last argument must be of type time_t
. This function formats its value as an UTC based, ISO 8601 compliant date.The various binding functions (rtm_api_call_method
, rtm_api_call_authenticated_method
, rtm_api_param_add
, etc) manage all necessary resource allocation and de-allocation.
However, if one wants to manually manage the internal parameter state, rtm_api_param_init
, rtm_api_param_clear
and rtm_api_param_reset
(which calls rtm_api_param_clear
then rtm_api_param_init
) can be used.
These bindings are at a proof of concept stage, and any feedback would be greatly appreciated.