小编ccc*_*ccc的帖子

在C中使用libcurl和liboauth发布推文

我正在尝试使用以下代码向Twitter发布推文,但不断收到错误"无法验证您","代码":32":

 curl_global_init(CURL_GLOBAL_ALL);
 CURL *curl = curl_easy_init();

 char *signedurl = malloc(sizeof(char) * 1024); /* Not how it will be, but works in this example. */

 char *url = "https://api.twitter.com/1.1/statuses/update.json";
 signedurl = oauth_sign_url2(url, NULL, OA_HMAC, "POST", consumer_key, consumer_secret, user_token, user_secret);
 char *status = "status=test";

 curl_easy_setopt(curl, CURLOPT_URL, signedurl); /* URL we're connecting to, after being signed by oauthlib */
 curl_easy_setopt(curl, CURLOPT_USERAGENT, "dummy-string"); /* Not the actual string, just a dummy for this example */
 curl_easy_setopt(curl, CURLOPT_POST, 1);
 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, status);
 //curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); …
Run Code Online (Sandbox Code Playgroud)

c twitter libcurl http-headers twitter-oauth

5
推荐指数
1
解决办法
1292
查看次数

标签 统计

c ×1

http-headers ×1

libcurl ×1

twitter ×1

twitter-oauth ×1