Skip to content

Commit

Permalink
Facebook: first server query
Browse files Browse the repository at this point in the history
  • Loading branch information
georgehazan committed Jun 15, 2019
1 parent 4275676 commit 34967c6
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
2 changes: 2 additions & 0 deletions protocols/Facebook/src/main.cpp
Expand Up @@ -21,6 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
#include "version.h"

#pragma comment(lib, "Rpcrt4.lib")

CMPlugin g_plugin;

bool g_bMessageState;
Expand Down
10 changes: 10 additions & 0 deletions protocols/Facebook/src/proto.cpp
Expand Up @@ -23,6 +23,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
FacebookProto::FacebookProto(const char *proto_name, const wchar_t *username) :
PROTO<FacebookProto>(proto_name, username)
{
szDeviceID = getMStringA(DBKEY_DEVICE_ID);
if (szDeviceID.IsEmpty()) {
UUID deviceId;
UuidCreate(&deviceId);
RPC_CSTR szId;
UuidToStringA(&deviceId, &szId);
szDeviceID = szId;
setString(DBKEY_DEVICE_ID, szDeviceID);
RpcStringFreeA(&szId);
}

}

Expand Down
12 changes: 12 additions & 0 deletions protocols/Facebook/src/proto.h
Expand Up @@ -20,8 +20,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#pragma once

#include "../../../miranda-private-keys/Facebook/app_secret.h"

class FacebookProto;

struct AsyncHttpRequest : public MTHttpRequest<FacebookProto>
{
void CalcSig();
};

class FacebookProto : public PROTO<FacebookProto>
{
AsyncHttpRequest* CreateGraphql(const char *szName, const char *szMethod);

CMStringA szDeviceID;

public:
FacebookProto(const char *proto_name, const wchar_t *username);
Expand Down
48 changes: 48 additions & 0 deletions protocols/Facebook/src/server.cpp
@@ -0,0 +1,48 @@
/*
Facebook plugin for Miranda NG
Copyright © 2019 Miranda NG team
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/>.
*/

#include "stdafx.h"

AsyncHttpRequest* FacebookProto::CreateGraphql(const char *szName, const char *szMethod)
{
AsyncHttpRequest *pReq = new AsyncHttpRequest();
pReq->requestType = REQUEST_POST;
pReq->szUrl = "https://graph.facebook.com/graphql";
pReq << CHAR_PARAM("api_key", FB_APP_KEY) << CHAR_PARAM("device_id", szDeviceID) << CHAR_PARAM("fb_api_req_friendly_name", szName)
<< CHAR_PARAM("format", "json") << CHAR_PARAM("method", szMethod);

CMStringA szLocale = getMStringA(DBKEY_LOCALE);
if (szLocale.IsEmpty())
szLocale = "en";
pReq << CHAR_PARAM("locale", szLocale);

unsigned int id;
Utils_GetRandom(&id, sizeof(id));
id &= ~0x80000000;
pReq << INT_PARAM("queryid", id);

return pReq;
}

void AsyncHttpRequest::CalcSig()
{
CMStringA szSrc = m_szParam;
szSrc.Append(FB_APP_SECRET);
}

0 comments on commit 34967c6

Please sign in to comment.