-
Notifications
You must be signed in to change notification settings - Fork 0
/
oauth.h
1201 lines (1114 loc) · 26 KB
/
oauth.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <TimeLib.h>
#include <stdint.h>
#include <NTPClient.h>
#include <time.h>
#include <vector>
#include <string>
#include <algorithm>
class misc
{
private:
static void url_encode_(const char *ptr, const char *end, std::vector<char> *out)
{
while (ptr < end)
{
int c = (unsigned char)*ptr;
ptr++;
if (isalnum(c) || strchr("_.-~", c))
{
print(out, c);
}
else
{
char tmp[10];
sprintf(tmp, "%%%02X", c);
print(out, tmp[0]);
print(out, tmp[1]);
print(out, tmp[2]);
}
}
}
static void url_decode_(const char *ptr, const char *end, std::vector<char> *out)
{
while (ptr < end)
{
int c = (unsigned char)*ptr;
ptr++;
if (c == '+')
{
c = ' ';
}
else if (c == '%' && isxdigit((unsigned char)ptr[0]) && isxdigit((unsigned char)ptr[1]))
{
char tmp[3]; // '%XX'
tmp[0] = ptr[0];
tmp[1] = ptr[1];
tmp[2] = 0;
c = strtol(tmp, NULL, 16);
ptr += 2;
}
print(out, c);
}
}
public:
static void print(std::vector<char> *out, char c)
{
out->push_back(c);
}
static void print(std::vector<char> *out, char const *begin, char const *end)
{
out->insert(out->end(), begin, end);
}
static void print(std::vector<char> *out, char const *ptr, size_t len)
{
print(out, ptr, ptr + len);
}
static void print(std::vector<char> *out, char const *s)
{
print(out, s, s + strlen(s));
}
static void print(std::vector<char> *out, std::string const &s)
{
print(out, s.c_str(), s.size());
}
static std::string to_stdstr(std::vector<char> const &vec)
{
if (!vec.empty())
{
char const *begin = &vec.at(0);
char const *end = begin + vec.size();
return std::string(begin, end);
}
return std::string();
}
static std::string url_encode(char const *str, char const *end)
{
if (!str)
{
return std::string();
}
std::vector<char> out;
out.reserve(end - str + 10);
url_encode_(str, end, &out);
return to_stdstr(out);
}
static std::string url_decode(char const *str, char const *end)
{
if (!str)
{
return std::string();
}
std::vector<char> out;
out.reserve(end - str + 10);
url_decode_(str, end, &out);
return to_stdstr(out);
}
static std::string url_encode(char const *str, size_t len)
{
return url_encode(str, str + len);
}
static std::string url_decode(char const *str, size_t len)
{
return url_decode(str, str + len);
}
static std::string url_encode(char const *str)
{
return url_encode(str, strlen(str));
}
static std::string url_decode(const char *str)
{
return url_decode(str, strlen(str));
}
static std::string url_encode(std::string const &str)
{
char const *begin = str.c_str();
char const *end = begin + str.size();
char const *ptr = begin;
while (ptr < end)
{
int c = (unsigned char)*ptr;
if (isalnum(c) || strchr("_.-~", c))
{
}
else
{
break;
}
ptr++;
}
if (ptr == end)
{
return str;
}
std::vector<char> out;
out.reserve(str.size() + 10);
out.insert(out.end(), begin, ptr);
url_encode_(ptr, end, &out);
return to_stdstr(out);
}
static std::string url_decode(std::string const &str)
{
char const *begin = str.c_str();
char const *end = begin + str.size();
char const *ptr = begin;
while (ptr < end)
{
int c = *ptr & 0xff;
if (c == '+' || c == '%')
{
break;
}
ptr++;
}
if (ptr == end)
{
return str;
}
std::vector<char> out;
out.reserve(str.size() + 10);
out.insert(out.end(), begin, ptr);
url_decode_(ptr, end, &out);
return to_stdstr(out);
}
};
class base64
{
private:
static const unsigned char PAD = '=';
static unsigned char enc(int c)
{
static const unsigned char _encode_table[] = {
0x41,
0x42,
0x43,
0x44,
0x45,
0x46,
0x47,
0x48,
0x49,
0x4a,
0x4b,
0x4c,
0x4d,
0x4e,
0x4f,
0x50,
0x51,
0x52,
0x53,
0x54,
0x55,
0x56,
0x57,
0x58,
0x59,
0x5a,
0x61,
0x62,
0x63,
0x64,
0x65,
0x66,
0x67,
0x68,
0x69,
0x6a,
0x6b,
0x6c,
0x6d,
0x6e,
0x6f,
0x70,
0x71,
0x72,
0x73,
0x74,
0x75,
0x76,
0x77,
0x78,
0x79,
0x7a,
0x30,
0x31,
0x32,
0x33,
0x34,
0x35,
0x36,
0x37,
0x38,
0x39,
0x2b,
0x2f,
};
return _encode_table[c & 63];
}
static unsigned char dec(int c)
{
static const unsigned char _decode_table[] = {
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0x3e,
0xff,
0xff,
0xff,
0x3f,
0x34,
0x35,
0x36,
0x37,
0x38,
0x39,
0x3a,
0x3b,
0x3c,
0x3d,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0x00,
0x01,
0x02,
0x03,
0x04,
0x05,
0x06,
0x07,
0x08,
0x09,
0x0a,
0x0b,
0x0c,
0x0d,
0x0e,
0x0f,
0x10,
0x11,
0x12,
0x13,
0x14,
0x15,
0x16,
0x17,
0x18,
0x19,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0x1a,
0x1b,
0x1c,
0x1d,
0x1e,
0x1f,
0x20,
0x21,
0x22,
0x23,
0x24,
0x25,
0x26,
0x27,
0x28,
0x29,
0x2a,
0x2b,
0x2c,
0x2d,
0x2e,
0x2f,
0x30,
0x31,
0x32,
0x33,
0xff,
0xff,
0xff,
0xff,
0xff,
};
return _decode_table[c & 127];
}
public:
static void encode(char const *src, size_t length, std::vector<char> *out)
{
size_t srcpos, dstlen, dstpos;
dstlen = (length + 2) / 3 * 4;
out->resize(dstlen);
if (dstlen == 0)
{
return;
}
char *dst = &out->at(0);
dstpos = 0;
for (srcpos = 0; srcpos < length; srcpos += 3)
{
int v = (unsigned char)src[srcpos] << 16;
if (srcpos + 1 < length)
{
v |= (unsigned char)src[srcpos + 1] << 8;
if (srcpos + 2 < length)
{
v |= (unsigned char)src[srcpos + 2];
dst[dstpos + 3] = enc(v);
}
else
{
dst[dstpos + 3] = PAD;
}
dst[dstpos + 2] = enc(v >> 6);
}
else
{
dst[dstpos + 2] = PAD;
dst[dstpos + 3] = PAD;
}
dst[dstpos + 1] = enc(v >> 12);
dst[dstpos] = enc(v >> 18);
dstpos += 4;
}
}
static void decode(char const *src, size_t length, std::vector<char> *out)
{
unsigned char const *begin = (unsigned char const *)src;
unsigned char const *end = begin + length;
unsigned char const *ptr = begin;
out->clear();
out->reserve(length * 3 / 4);
int count = 0;
int bits = 0;
while (1)
{
if (isspace(*ptr))
{
ptr++;
}
else
{
unsigned char c = 0xff;
if (ptr < end && *ptr < 0x80)
{
c = dec(*ptr);
}
if (c < 0x40)
{
bits = (bits << 6) | c;
count++;
}
else
{
if (count < 4)
{
bits <<= (4 - count) * 6;
}
c = 0xff;
}
if (count == 4 || c == 0xff)
{
if (count >= 2)
{
out->push_back(bits >> 16);
if (count >= 3)
{
out->push_back(bits >> 8);
if (count == 4)
{
out->push_back(bits);
}
}
}
count = 0;
bits = 0;
if (c == 0xff)
{
break;
}
}
ptr++;
}
}
}
static void encode(std::vector<char> const *src, std::vector<char> *out)
{
encode(&src->at(0), src->size(), out);
}
static void decode(std::vector<char> const *src, std::vector<char> *out)
{
decode(&src->at(0), src->size(), out);
}
static void encode(char const *src, std::vector<char> *out)
{
encode((char const *)src, strlen(src), out);
}
static void decode(char const *src, std::vector<char> *out)
{
decode((char const *)src, strlen(src), out);
}
static inline std::string to_s_(std::vector<char> const *vec)
{
if (!vec || vec->empty())
return std::string();
return std::string((char const *)&(*vec)[0], vec->size());
}
static inline std::string encode(std::string const &src)
{
std::vector<char> vec;
encode((char const *)src.c_str(), src.size(), &vec);
return to_s_(&vec);
}
static inline std::string decode(std::string const &src)
{
std::vector<char> vec;
decode((char const *)src.c_str(), src.size(), &vec);
return to_s_(&vec);
}
};
class sha1
{
public:
enum
{
Success = 0,
Null, /* Null pointer parameter */
InputTooLong, /* input data too long */
StateError /* called Input after Result */
};
public:
static const int HashSize = 20;
struct Context
{
uint32_t Intermediate_Hash[HashSize / 4]; /* Message Digest */
uint32_t Length_Low; /* Message length in bits */
uint32_t Length_High; /* Message length in bits */
/* Index into message block array */
int_least16_t Message_Block_Index;
uint8_t Message_Block[64]; /* 512-bit message blocks */
int Computed; /* Is the digest computed? */
int Corrupted; /* Is the message digest corrupted? */
};
static uint32_t CircularShift(uint32_t bits, uint32_t word)
{
return ((word) << (bits)) | ((word) >> (32 - (bits)));
}
static void PadMessage(Context *context)
{
if (context->Message_Block_Index > 55)
{
context->Message_Block[context->Message_Block_Index++] = 0x80;
while (context->Message_Block_Index < 64)
{
context->Message_Block[context->Message_Block_Index++] = 0;
}
ProcessMessageBlock(context);
while (context->Message_Block_Index < 56)
{
context->Message_Block[context->Message_Block_Index++] = 0;
}
}
else
{
context->Message_Block[context->Message_Block_Index++] = 0x80;
while (context->Message_Block_Index < 56)
{
context->Message_Block[context->Message_Block_Index++] = 0;
}
}
context->Message_Block[56] = context->Length_High >> 24;
context->Message_Block[57] = context->Length_High >> 16;
context->Message_Block[58] = context->Length_High >> 8;
context->Message_Block[59] = context->Length_High;
context->Message_Block[60] = context->Length_Low >> 24;
context->Message_Block[61] = context->Length_Low >> 16;
context->Message_Block[62] = context->Length_Low >> 8;
context->Message_Block[63] = context->Length_Low;
ProcessMessageBlock(context);
}
static void ProcessMessageBlock(Context *context)
{
const uint32_t K[] = {
0x5A827999,
0x6ED9EBA1,
0x8F1BBCDC,
0xCA62C1D6};
int t;
uint32_t temp;
uint32_t W[80];
uint32_t A, B, C, D, E;
for (t = 0; t < 16; t++)
{
W[t] = context->Message_Block[t * 4] << 24;
W[t] |= context->Message_Block[t * 4 + 1] << 16;
W[t] |= context->Message_Block[t * 4 + 2] << 8;
W[t] |= context->Message_Block[t * 4 + 3];
}
for (t = 16; t < 80; t++)
{
W[t] = CircularShift(1, W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16]);
}
A = context->Intermediate_Hash[0];
B = context->Intermediate_Hash[1];
C = context->Intermediate_Hash[2];
D = context->Intermediate_Hash[3];
E = context->Intermediate_Hash[4];
for (t = 0; t < 20; t++)
{
temp = CircularShift(5, A) + ((B & C) | ((~B) & D)) + E + W[t] + K[0];
E = D;
D = C;
C = CircularShift(30, B);
B = A;
A = temp;
}
for (t = 20; t < 40; t++)
{
temp = CircularShift(5, A) + (B ^ C ^ D) + E + W[t] + K[1];
E = D;
D = C;
C = CircularShift(30, B);
B = A;
A = temp;
}
for (t = 40; t < 60; t++)
{
temp = CircularShift(5, A) + ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2];
E = D;
D = C;
C = CircularShift(30, B);
B = A;
A = temp;
}
for (t = 60; t < 80; t++)
{
temp = CircularShift(5, A) + (B ^ C ^ D) + E + W[t] + K[3];
E = D;
D = C;
C = CircularShift(30, B);
B = A;
A = temp;
}
context->Intermediate_Hash[0] += A;
context->Intermediate_Hash[1] += B;
context->Intermediate_Hash[2] += C;
context->Intermediate_Hash[3] += D;
context->Intermediate_Hash[4] += E;
context->Message_Block_Index = 0;
}
public:
static int Reset(Context *context)
{
if (!context)
{
return Null;
}
context->Length_Low = 0;
context->Length_High = 0;
context->Message_Block_Index = 0;
context->Intermediate_Hash[0] = 0x67452301;
context->Intermediate_Hash[1] = 0xEFCDAB89;
context->Intermediate_Hash[2] = 0x98BADCFE;
context->Intermediate_Hash[3] = 0x10325476;
context->Intermediate_Hash[4] = 0xC3D2E1F0;
context->Computed = 0;
context->Corrupted = 0;
return Success;
}
static int Result(Context *context, uint8_t Message_Digest[])
{
int i;
if (!context || !Message_Digest)
{
return Null;
}
if (context->Corrupted)
{
return context->Corrupted;
}
if (!context->Computed)
{
PadMessage(context);
for (i = 0; i < 64; ++i)
{
/* message may be sensitive, clear it out */
context->Message_Block[i] = 0;
}
context->Length_Low = 0; /* and clear length */
context->Length_High = 0;
context->Computed = 1;
}
for (i = 0; i < HashSize; ++i)
{
Message_Digest[i] = context->Intermediate_Hash[i >> 2] >> 8 * (3 - (i & 0x03));
}
return Success;
}
static int Input(Context *context, const uint8_t *message_array, unsigned int length)
{
if (!length)
{
return Success;
}
if (!context || !message_array)
{
return Null;
}
if (context->Computed)
{
context->Corrupted = StateError;
return StateError;
}
if (context->Corrupted)
{
return context->Corrupted;
}
while (length-- && !context->Corrupted)
{
context->Message_Block[context->Message_Block_Index++] = (*message_array & 0xFF);
context->Length_Low += 8;
if (context->Length_Low == 0)
{
context->Length_High++;
if (context->Length_High == 0)
{
/* Message is too long */
context->Corrupted = 1;
}
}
if (context->Message_Block_Index == 64)
{
ProcessMessageBlock(context);
}
message_array++;
}
return Success;
}
};
class oauth
{
public:
class Keys
{
public:
std::string consumer_key;
std::string consumer_sec;
std::string accesstoken;
std::string accesstoken_sec;
Keys()
{
}
Keys(std::string consumer_key, std::string consumer_sec, std::string accesstoken, std::string accesstoken_sec)
: consumer_key(consumer_key), consumer_sec(consumer_sec), accesstoken(accesstoken), accesstoken_sec(accesstoken_sec)
{
}
};
enum http_method_t
{
GET,
POST,
};
struct Request
{
std::string url;
std::string post;
std::string getdata;
std::string right;
};
static Request sign(const char *url, http_method_t http_method, Keys const &keys, time_t currentTime)
{
std::vector<std::string> vec;
split_url(url, &vec);
process_(&vec, http_method, keys, currentTime);
if (http_method == POST)
{
Request req;
req.post = oauth::build_url_with_quotes(vec, 1);
Serial.print("req.post: ");
Serial.println(req.post.c_str());
req.url = vec.at(0);
return req;
}
else if (http_method == GET)
{
Request req;
// req.timevalue = currentTime;
Serial.println("sign started");
// req.getdata = oauth::build_oauth_auth(vec, 1);
req.getdata = oauth::build_url_with_quotes(vec, 1);
Serial.print("sign getdata: ");
Serial.println(req.getdata.c_str());
req.right = oauth::split_url_right(url);
Serial.print("sign right: ");
Serial.println(req.right.c_str());
req.url = vec.at(0);
Serial.print("sign url: ");
Serial.println(req.url.c_str());
return req;
}
else
{
Request req;
req.url = oauth::build_url(vec, 0);
return req;
}
}
private:
static std::string encode_base64(const unsigned char *src, int size)
{
std::vector<char> vec;
base64::encode((char const *)src, size, &vec);
return misc::to_stdstr(vec);
}
static std::string decode_base64(const char *src)
{
std::vector<char> vec;
base64::decode(src, &vec);
return misc::to_stdstr(vec);
}
static std::string url_escape(const char *string)
{
return misc::url_encode(string);
}
static std::string url_unescape(const char *string)
{
return misc::url_decode(string);
}
static void process_(std::vector<std::string> *args, http_method_t http_method, const Keys &keys, time_t timevalue)
{
auto to_s = [](int v) -> std::string
{
char tmp[100];
sprintf(tmp, "%d", v);
return tmp;
};
{
auto nonce = [](time_t timevalue)
{
static const char *chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
const unsigned int max = 26 + 26 + 10 + 1;
char tmp[50];
srand((unsigned int)timevalue);
// int len = 15 + rand() % 16;
int len = 42; // New twitter API requires 42 characters
for (int i = 0; i < len; i++)
{
tmp[i] = chars[rand() % max];
}
return std::string(tmp, len);
};
auto is_key_contains = [](std::vector<std::string> const &argv, std::string const &key)
{
size_t keylen = key.size();
for (std::string const &s : argv)
{
if (strncmp(s.c_str(), key.c_str(), keylen) == 0 && s[keylen] == '=')
{
return true;
}
}
return false;
};
std::string oauth_nonce = "oauth_nonce";
if (!is_key_contains(*args, oauth_nonce))
{
oauth_nonce += '=';
oauth_nonce += nonce(timevalue);
args->push_back(oauth_nonce);
}
std::string oauth_timestamp = "oauth_timestamp";
if (!is_key_contains(*args, oauth_timestamp))
{
oauth_timestamp += '=';
oauth_timestamp += to_s((int)timevalue);
args->push_back(oauth_timestamp);
}
if (!keys.accesstoken.empty())
{
std::string oauth_token = "oauth_token";
oauth_token += '=';
oauth_token += keys.accesstoken;
args->push_back(oauth_token);
}
std::string oauth_consumer_key = "oauth_consumer_key";
oauth_consumer_key += '=';
oauth_consumer_key += keys.consumer_key;
args->push_back(oauth_consumer_key);
std::string oauth_signature_method = "oauth_signature_method";
oauth_signature_method += '=';
oauth_signature_method += "HMAC-SHA1";
args->push_back(oauth_signature_method);
std::string oauth_version = "oauth_version";
if (!is_key_contains(*args, oauth_version))
{
oauth_version += '=';
oauth_version += "1.0";
args->push_back(oauth_version);
}
}
std::sort(args->begin() + 1, args->end());
auto Combine = [](std::initializer_list<std::string> list)
{
std::string text;
for (std::string const &s : list)
{
if (!s.empty())
{
if (!text.empty())
{
text += '&';
}
text += misc::url_encode(s);
}
}
return text;
};
std::string query = oauth::build_url(*args, 1);
std::string httpmethod;
if (http_method == http_method_t::GET)
{
httpmethod = "GET";
}
else if (http_method == http_method_t::POST)
{