about summary refs log tree commit diff stats
path: root/src/client.h
blob: 3a133e4acd67eb0accd63b262c44aec3b638b7d7 (plain) (blame)
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
#ifndef TWITTER_H_ABFF6A12
#define TWITTER_H_ABFF6A12

#include "codes.h"
#include "tweet.h"
#include "auth.h"
#include <list>
#include <curl_easy.h>
#include <curl_header.h>

namespace OAuth {
  class Consumer;
  class Token;
  class Client;
};

namespace twitter {
  
  class client {
    public:
      client(const auth& _auth);
      ~client();
      
      response updateStatus(std::string msg, tweet& result, std::list<long> media_ids = {});
      response uploadMedia(std::string media_type, const char* data, long data_length, long& media_id);
      
    private:
      OAuth::Consumer* _oauth_consumer;
      OAuth::Token* _oauth_token;
      OAuth::Client* _oauth_client;
      
      bool performGet(std::string url, long& response_code, json& result);
      bool performPost(std::string url, std::string dataStr, long& response_code, json& result);
      bool performMultiPost(std::string url, const curl_httppost* fields, long& response_code, json& result);
      response codeForError(int httpcode, json errors) const;
  };
  
};

#endif /* end of include guard: TWITTER_H_ABFF6A12 */