This repository has been archived by the owner on Sep 23, 2019. It is now read-only.
/
qtweetgeoplaceid.cpp
70 lines (61 loc) · 2.03 KB
/
qtweetgeoplaceid.cpp
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
/* Copyright (c) 2010, Antonie Jovanoski
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
*/
#include <QtDebug>
#include <QNetworkRequest>
#include <QNetworkReply>
#include "qtweetgeoplaceid.h"
#include "qtweetplace.h"
#include "qtweetconvert.h"
/**
* Constructor
*/
QTweetGeoPlaceID::QTweetGeoPlaceID(QObject *parent) :
QTweetNetBase(parent)
{
}
/**
* Constructor
* @param oauthTwitter OAuthTwitter object
* @param parent parent QObject
*/
QTweetGeoPlaceID::QTweetGeoPlaceID(OAuthTwitter *oauthTwitter, QObject *parent) :
QTweetNetBase(oauthTwitter, parent)
{
}
/**
* Starts fetching information about place
* @param placeid a place in the world. These ID's can be retrieved from QTweetGeoReverseGeoCode
*/
void QTweetGeoPlaceID::get(const QString &placeid)
{
QUrl url(QString("https://api.twitter.com/1/geo/id/%1.json").arg(placeid));
QNetworkRequest req(url);
if (isAuthenticationEnabled()) {
QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET);
req.setRawHeader(AUTH_HEADER, oauthHeader);
}
QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req);
connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
void QTweetGeoPlaceID::parseJsonFinished(cJSON *root)
{
QTweetPlace place = QTweetConvert::cJSONToPlaceRecursive(root);
emit parsedPlace(place);
}