如何在Pascal中创建QuickBlox会话

时间:2015-05-27 08:42:50

标签: pascal quickblox

我在Pascal上创建QuickBlox会话时遇到了麻烦。

此处未找到任何示例http://quickblox.com/developers/Authentication_and_Authorization#Examples

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:3)

以下是如何从Pascal开始:

program qbsession;

uses fphttpclient,sysutils;

var
  HTTP: TFPHTTPClient;
var 
  qbresponse: String;

const 
  applicationId: String = '92';
  authKey: String = 'wJHdOcQSxXQGWx5';
  authSecret: String = 'BTFsj7Rtt27DAmT';

var
  randomValue: Integer;
  timestamp: Int64;
  body: String;
  signature: String;

begin
  Randomize;

  randomValue := Random(5000);
  timestamp := Trunc((Now - EncodeDate(1970, 1 ,1)) * 24 * 60 * 60);

  HTTP := TFPHTTPClient.Create(nil);

  // This is still to figure out how to do
  // It should be some examples on Pascal how to do it
  // http://quickblox.com/developers/Authentication_and_Authorization#Signature_generation
  signature := '...';

  body := 'application_id=' + applicationId + '&auth_key=' + authKey 
   + '&timestamp=' + IntToStr(timestamp) + '&nonce=' + IntToStr(randomValue) 
   + '&signature=' + signature;

  WriteLn('body: ' + body);

  qbresponse := HTTP.FormPost('http://api.quickblox.com/session.json', body);

  WriteLn('Response: ' + qbresponse);

  HTTP.Free;
end.