Changeset a7b9ec7 for protocols/twitter
- Timestamp:
- 2010-05-23T13:49:54Z (15 years ago)
- Branches:
- master
- Children:
- 186bd04
- Parents:
- bb5ce4d1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/twitter/twitter_lib.c
rbb5ce4d1 ra7b9ec7 117 117 } 118 118 119 /* Warning: May return a malloc()ed value, which will be free()d on the next 120 call. Only for short-term use. */ 121 static char *twitter_parse_error(struct http_request *req) 122 { 123 static char *ret = NULL; 124 struct xt_parser *xp; 125 struct xt_node *node; 126 char *err_s = NULL; 127 128 g_free(ret); 129 ret = NULL; 130 131 xp = xt_new(NULL, NULL); 132 xt_feed(xp, req->reply_body, req->body_size); 133 134 if ((node = xt_find_node(xp->root, "hash")) && 135 (node = xt_find_node(node->children, "error")) && 136 node->text_len > 0) 137 err_s = node->text; 138 139 if (err_s) 140 { 141 ret = g_strdup_printf("%s (%s)", req->status_string, err_s); 142 xt_free(xp); 143 return ret; 144 } 145 else 146 { 147 return req->status_string; 148 } 149 } 150 119 151 static void twitter_http_get_friends_ids(struct http_request *req); 120 152 … … 124 156 void twitter_get_friends_ids(struct im_connection *ic, int next_cursor) 125 157 { 126 struct twitter_data *td = ic->proto_data;127 128 158 // Primitive, but hey! It works... 129 159 char* args[2]; … … 196 226 // It didn't go well, output the error and return. 197 227 if (++td->http_fails >= 5) 198 imcb_error(ic, "Could not retrieve friends . HTTP STATUS: %d", req->status_code);228 imcb_error(ic, "Could not retrieve friends: %s", twitter_parse_error(req)); 199 229 200 230 return; … … 526 556 // It didn't go well, output the error and return. 527 557 if (++td->http_fails >= 5) 528 imcb_error(ic, "Could not retrieve " TWITTER_HOME_TIMELINE_URL " . HTTP STATUS: %d", req->status_code);558 imcb_error(ic, "Could not retrieve " TWITTER_HOME_TIMELINE_URL ": %s", twitter_parse_error(req)); 529 559 530 560 return; … … 578 608 // It didn't go well, output the error and return. 579 609 if (++td->http_fails >= 5) 580 imcb_error(ic, "Could not retrieve " TWITTER_SHOW_FRIENDS_URL " HTTP STATUS: %d", req->status_code);610 imcb_error(ic, "Could not retrieve " TWITTER_SHOW_FRIENDS_URL ": %s", twitter_parse_error(req)); 581 611 582 612 return; … … 617 647 void twitter_get_statuses_friends(struct im_connection *ic, int next_cursor) 618 648 { 619 struct twitter_data *td = ic->proto_data;620 621 649 char* args[2]; 622 650 args[0] = "cursor"; … … 642 670 if (req->status_code != 200) { 643 671 // It didn't go well, output the error and return. 644 imcb_error(ic, "Could not post message ... HTTP STATUS: %d", req->status_code);672 imcb_error(ic, "Could not post message: %s", twitter_parse_error(req)); 645 673 return; 646 674 } … … 652 680 void twitter_post_status(struct im_connection *ic, char* msg) 653 681 { 654 struct twitter_data *td = ic->proto_data;655 656 682 char* args[2]; 657 683 args[0] = "status"; … … 667 693 void twitter_direct_messages_new(struct im_connection *ic, char *who, char *msg) 668 694 { 669 struct twitter_data *td = ic->proto_data;670 671 695 char* args[4]; 672 696 args[0] = "screen_name";
Note: See TracChangeset
for help on using the changeset viewer.