3 #include "twittersocket.h"
5 TwitterSocket::TwitterSocket(QString user
, QString pass
, QObject
*parent
) : QHttp(parent
)
7 setHost("twitter.com");
9 QObject::connect( this, SIGNAL( done(bool) ), this, SLOT(done( bool) ) );
12 void TwitterSocket::accountValid()
14 get(QLatin1String("/statuses/friends_timeline.xml"));
17 void TwitterSocket::update(QString message
)
19 QHttpRequestHeader
header("POST", "/statuses/update.xml");
20 header
.setValue("Host", "twitter.com");
22 // Twitterrific manages to get its name on the page using the source
23 // tag, but it doesn't seem to work for us :/
24 const QString
msg("source=Squawker&status="+message
);
25 request(header
, msg
.toAscii());
28 void TwitterSocket::timeline()
30 get(QLatin1String("/statuses/friends_timeline.xml"));
33 void TwitterSocket::done( bool error
)
35 QString results
= readAll();
37 // Hack to work around bug in Qt4.2 basic auth. Fixed in 4.3
38 // (It doesn't report an error when incorrect credentials are supplied)
39 if ( results
== "Could not authenticate you")
40 emit
result(true, QLatin1String("Authentication denied"), NULL
);
42 emit
result(error
, errorString(), results
);