summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/Facebook/src/db.h1
-rw-r--r--protocols/Facebook/src/server.cpp24
2 files changed, 15 insertions, 10 deletions
diff --git a/protocols/Facebook/src/db.h b/protocols/Facebook/src/db.h
index 89d908ac9a..73d0b249a4 100644
--- a/protocols/Facebook/src/db.h
+++ b/protocols/Facebook/src/db.h
@@ -42,6 +42,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DBKEY_MESSAGE_ID "LastMessageId"
#define DBKEY_MESSAGE_READ "LastMsgReadTime"
#define DBKEY_MESSAGE_READERS "MessageReaders"
+#define DBKEY_TOKEN "Token"
// Thread specific DB keys
#define DBKEY_CHAT_CAN_REPLY "CanReply"
diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp
index bcf2d2fdfe..dba8178fa8 100644
--- a/protocols/Facebook/src/server.cpp
+++ b/protocols/Facebook/src/server.cpp
@@ -29,17 +29,21 @@ void FacebookProto::OnLoggedOut()
void FacebookProto::ServerThread(void *)
{
- auto *pReq = CreateRequest("authenticate", "auth.login");
- pReq->m_szUrl = FB_HOST_BAPI "/method/auth.login";
- pReq << CHAR_PARAM("email", getMStringA("Email")) << CHAR_PARAM("password", getMStringA("Password"));
- pReq->CalcSig();
-
- JsonReply reply(ExecuteRequest(pReq));
- if (reply.error()) {
+ m_szAuthToken = getMStringA(DBKEY_TOKEN);
+ if (m_szAuthToken.IsEmpty()) {
+ auto *pReq = new AsyncHttpRequest();
+ pReq->requestType = REQUEST_GET;
+ pReq->flags = NLHRF_HTTP11 | NLHRF_REDIRECT;
+ pReq->m_szUrl = "https://www.facebook.com/v3.3/dialog/oauth?client_id=478386432928815&redirect_uri=https://oauth.miranda-ng.org/facebook.php&state=qq";
+
+ JsonReply reply(ExecuteRequest(pReq));
+ if (reply.error()) {
FAIL:
- ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_FAILED, (HANDLE)m_iStatus, m_iDesiredStatus);
+ ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_FAILED, (HANDLE)m_iStatus, m_iDesiredStatus);
- m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
- ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)m_iStatus, m_iDesiredStatus);
+ m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
+ ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)m_iStatus, m_iDesiredStatus);
+ return;
+ }
}
}