]> ToastFreeware Gitweb - gregoa/bti.git/commitdiff
Merge https://github.com/leif81/bti into main tree
authorGreg Kroah-Hartman <gregkh@suse.de>
Wed, 12 Jan 2011 19:01:39 +0000 (11:01 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 12 Jan 2011 19:02:39 +0000 (11:02 -0800)
This fixes an issue with twitter queries for non-oauth portions
of the api.

1  2 
bti.c

diff --combined bti.c
index 26d792832ac5c444292f74cf99d503456198fdb7,a7fa43c5ef3057d5c285bc099fcd62c8d9804e2f..4ad5b541052a2ce7115a1255fca341e98404e194
--- 1/bti.c
--- 2/bti.c
+++ b/bti.c
@@@ -98,6 -98,7 +98,7 @@@ struct session 
        int dry_run;
        int page;
        int no_oauth;
+       int guest;
        enum host host;
        enum action action;
        void *readline_handle;
@@@ -592,7 -593,7 +593,7 @@@ static int send_request(struct session 
        if (!session->hosturl)
                session->hosturl = strdup(twitter_host);
  
-       if (session->no_oauth) {
+       if (session->no_oauth || session->guest) {
                curl_buf = bti_curl_buffer_alloc(session->action);
                if (!curl_buf)
                        return -ENOMEM;
                        break;
                }
  
 -              if (is_post) {
 -                      req_url = oauth_sign_url2(endpoint, &postarg, OA_HMAC,
 -                                                NULL, session->consumer_key,
 -                                                session->consumer_secret,
 -                                                session->access_token_key,
 -                                                session->access_token_secret);
 -                      reply = oauth_http_post(req_url, postarg);
 -              } else {
 -                      req_url = oauth_sign_url2(endpoint, NULL, OA_HMAC, NULL,
 -                                                session->consumer_key,
 -                                                session->consumer_secret,
 -                                                session->access_token_key,
 -                                                session->access_token_secret);
 -                      reply = oauth_http_get(req_url, postarg);
 -              }
 +              dbg("%s\n", endpoint);
 +              if (!session->dry_run) {
 +                      if (is_post) {
 +                              req_url = oauth_sign_url2(endpoint, &postarg, OA_HMAC,
 +                                                        NULL, session->consumer_key,
 +                                                        session->consumer_secret,
 +                                                        session->access_token_key,
 +                                                        session->access_token_secret);
 +                              reply = oauth_http_post(req_url, postarg);
 +                      } else {
 +                              req_url = oauth_sign_url2(endpoint, NULL, OA_HMAC, NULL,
 +                                                        session->consumer_key,
 +                                                        session->consumer_secret,
 +                                                        session->access_token_key,
 +                                                        session->access_token_secret);
 +                              reply = oauth_http_get(req_url, postarg);
 +                      }
  
 -              dbg("%s\n", req_url);
 -              dbg("%s\n", reply);
 -              if (req_url)
 -                      free(req_url);
 +                      dbg("%s\n", req_url);
 +                      dbg("%s\n", reply);
 +                      if (req_url)
 +                              free(req_url);
 +              }
  
                if ((session->action != ACTION_UPDATE) &&
                                (session->action != ACTION_RETWEET))
@@@ -1547,11 -1545,17 +1548,17 @@@ int main(int argc, char *argv[], char *
  
        if (session->host == HOST_TWITTER) {
                if (!session->consumer_key || !session->consumer_secret) {
-                       fprintf(stderr,
-                               "Twitter no longer supports HTTP basic authentication.\n"
-                               "Both consumer key, and consumer secret are required"
-                               " for bti in order to behave as an OAuth consumer.\n");
-                       goto exit;
+                       if (session->action == ACTION_USER ||
+                                       session->action == ACTION_PUBLIC) {
+                               /* Some actions may still work without authentication */
+                               session->guest = 1;
+                       } else {
+                               fprintf(stderr,
+                                               "Twitter no longer supports HTTP basic authentication.\n"
+                                               "Both consumer key, and consumer secret are required"
+                                               " for bti in order to behave as an OAuth consumer.\n");
+                               goto exit;
+                       }
                }
                if (session->action == ACTION_GROUP) {
                        fprintf(stderr, "Groups only work in Identi.ca.\n");
                                      session->hostname);
                        session->password = strdup(password);
                }
-       } else {
+       } else if (!session->guest) {
                if (!session->access_token_key ||
                    !session->access_token_secret) {
                        request_access_token(session);