1//
2// Twitter.h
3//
4// A C++ implementation of a Twitter client based on the POCO Net library.
5//
6// Copyright (c) 2009-2013, Applied Informatics Software Engineering GmbH.
7// and Contributors.
8//
9// SPDX-License-Identifier: BSL-1.0
10//
11
12
13#ifndef Twitter_INCLUDED
14#define Twitter_INCLUDED
15
16
17#include "Poco/Poco.h"
18#include "Poco/Net/HTMLForm.h"
19#include "Poco/Util/AbstractConfiguration.h"
20#include "Poco/AutoPtr.h"
21
22
23class Twitter
24 /// A simple implementation of a Twitter API client
25 /// (see <http://dev.twitter.com> for more information).
26 ///
27 /// Currently, only the update message is supported.
28{
29public:
30 Twitter();
31 /// Creates the Twitter object, using
32 /// the default Twitter API URI (<http://api.twitter.com/1.1/statuses/>).
33
34 Twitter(const std::string& twitterURI);
35 /// Creates the Twitter object using the given Twitter API URI.
36
37 ~Twitter();
38 /// Destroys the Twitter object.
39
40 void login(const std::string& consumerKey, const std::string& consumerSecret, const std::string& token, const std::string& tokenSecret);
41 /// Specifies the OAuth authentication information used in all API calls.
42
43 Poco::Int64 update(const std::string& status);
44 /// Updates the user's status.
45 ///
46 /// Returns the ID of the newly created status.
47
48 Poco::AutoPtr<Poco::Util::AbstractConfiguration> invoke(const std::string& httpMethod, const std::string& twitterMethod, Poco::Net::HTMLForm& params);
49 /// Invokes the given method of the Twitter API, using the parameters
50 /// given in the Poco::Net::HTMLForm object. httpMethod must be GET or POST,
51 /// according to the Twitter API documentation.
52 ///
53 /// Returns a Poco::Util::JSONConfiguration with the server's response if the
54 /// server's HTTP response status code is 200 (OK).
55 /// Otherwise, throws a Poco::ApplicationException.
56
57 static const std::string TWITTER_URI;
58
59private:
60 Twitter(const Twitter&);
61 Twitter& operator = (const Twitter&);
62
63 std::string _uri;
64 std::string _consumerKey;
65 std::string _consumerSecret;
66 std::string _token;
67 std::string _tokenSecret;
68};
69
70
71#endif // Twitter_INCLUDED
72