#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void request_token_example_get(void) {
#if 0
const char *request_token_uri = "http://localhost/oauthtest.php?test=test";
const char *req_c_key = "17b09ea4c9a4121145936f0d7d8daa28047583796";
const char *req_c_secret = "942295b08ffce77b399419ee96ac65be";
#else
const char *request_token_uri = "http://term.ie/oauth/example/request_token.php";
const char *req_c_key = "key";
const char *req_c_secret = "secret";
#endif
char *res_t_key = NULL;
char *res_t_secret = NULL;
char *req_url = NULL;
char *req_hdr = NULL;
char *http_hdr= NULL;
char *reply;
int argc;
char **argv = NULL;
if (1) {
int i;
for (i=0;i<argc; i++)
printf("%d:%s\n", i, argv[i]);
}
NULL,
NULL,
req_c_key, req_c_secret, NULL, NULL);
http_hdr = malloc(strlen(req_hdr) + 55);
sprintf(http_hdr, "Authorization: OAuth realm=\"http://example.org/\", %s", req_hdr);
printf("request URL=%s\n", req_url);
printf("request header=%s\n\n", http_hdr);
if (!reply)
printf("HTTP request for an oauth request-token failed.\n");
else {
int rc;
char **rv = NULL;
printf("HTTP-reply: %s\n", reply);
if( rc==2
&& !strncmp(rv[0],"oauth_token=",11)
&& !strncmp(rv[1],"oauth_token_secret=",18) ){
res_t_key=strdup(&(rv[0][12]));
res_t_secret=strdup(&(rv[1][19]));
printf("key: '%s'\nsecret: '%s'\n",res_t_key, res_t_secret);
}
if(rv) free(rv);
}
if(req_url) free(req_url);
if(req_hdr) free(req_hdr);
if(http_hdr)free(http_hdr);
if(reply) free(reply);
if(res_t_key) free(res_t_key);
if(res_t_secret) free(res_t_secret);
}
int main (int argc, char **argv) {
request_token_example_get();
return (0);
}
OAuth.net implementation in POSIX-C.
int oauth_cmpstringp(const void *p1, const void *p2)
string compare function for oauth parameters.
char * oauth_serialize_url_sep(int argc, int start, char **argv, char *sep, int mod)
encode query parameters from an array.
@ OA_HMAC
use HMAC-SHA1 request signing method
int oauth_split_url_parameters(const char *url, char ***argv)
splits the given url into a parameter array.
void oauth_sign_array2_process(int *argcp, char ***argvp, char **postargs, OAuthMethod method, const char *http_method, const char *c_key, const char *c_secret, const char *t_key, const char *t_secret)
the back-end behind by /ref oauth_sign_array2.
char * oauth_http_get2(const char *u, const char *q, const char *customheader) attribute_deprecated
do a HTTP GET request, wait for it to finish and return the content of the reply.
void oauth_free_array(int *argcp, char ***argvp)
free array args