diff options
Diffstat (limited to 'tests/oauthbodyhash.c')
-rw-r--r-- | tests/oauthbodyhash.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/tests/oauthbodyhash.c b/tests/oauthbodyhash.c index eb3ff3f..b71eb08 100644 --- a/tests/oauthbodyhash.c +++ b/tests/oauthbodyhash.c @@ -3,7 +3,7 @@ * @file oauthbodysign.c * @author Robin Gareus <robin@gareus.org> * - * Copyright 2009 Robin Gareus <robin@gareus.org> + * Copyright 2009, 2012 Robin Gareus <robin@gareus.org> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -43,7 +43,14 @@ int my_data_post(char *url, char *data) { char *sig_url; bh=oauth_body_hash_data(strlen(data), data); - uh = oauth_catenc(2, url, bh); + uh = (char*) malloc((strlen(url)+strlen(bh)+2) * sizeof(char)); + if (!uh) return -1; + + strcat(uh, url); + strcat(uh, "?"); + strcat(uh, bh); + + printf("URL: %s\n", uh); req_url = oauth_sign_url2(uh, &postarg, OA_HMAC, NULL, c_key, c_secret, t_key, t_secret); printf("POST: %s?%s\n", req_url, postarg); if (uh) free(uh); @@ -53,8 +60,12 @@ int my_data_post(char *url, char *data) { reply = oauth_post_data(sig_url, data, strlen(data), "Content-Type: application/json"); if(sig_url) free(sig_url); - printf("REPLY: %s\n", reply); - if(reply) free(reply); + if (reply) { + printf("REPLY: %s\n", reply); + free(reply); + } else { + printf("Error performing the request\n"); + } return 0; } |