Code Monkey home page Code Monkey logo

fmx.restlight's Introduction

TRESTLight

  • uAppSettings.pas - хранит описание вашего приложения созданного в ВК
  • FMX.RESTLight.pas - модуль "общения" клиента с сервером
  • FMX.RESTLight.Types.pas - тут хранятся типы для работы TRESTLight
код постит текст на стену
var
  aFields: TArray<TmyRestParam>;
  aJSON: string;
begin
  SetLength(aFields, 5);

  aFields[0] := TmyRestParam.Create('access_token', FAuthToken.token, false);
  aFields[1] := TmyRestParam.Create('v', FVKApp.APIVersion, false);
  aFields[2] := TmyRestParam.Create('owner_id', FAuthToken.user_id, false);
  aFields[3] := TmyRestParam.Create('friends_only', '0', false);
  aFields[4] := TmyRestParam.Create('message', 'Тестовое сообщение <RESTLight>', false);

  TTask.Run(
    procedure
    begin
      aJSON := TRESTLight.Execute('wall.post', FVKApp, aFields);

      TThread.Synchronize(TThread.CurrentThread,
        procedure
        begin
          Memo1.Lines.Add('---- wall.post ----');
          Memo1.Lines.Add(aJSON);
        end);
    end);
отправка файлов на сервер
var
  aFields: TArray<TmyRestParam>;
  aJSON: string;
begin
   SetLength(aFields, 4);
   aFields[0] := TmyRestParam.Create('access_token', FAuthToken.token, false);
   aFields[1] := TmyRestParam.Create('v', FVKApp.APIVersion, false);
   aFields[2] := TmyRestParam.Create('owner_id', FAuthToken.user_id, false);
   aFields[3] := TmyRestParam.Create('photo', aUploadFile, true); // для файлов указывается !!!true!!!
	
  TTask.Run(
    procedure
    begin
      // для загрузки файлов использовать TRESTLight.Execute2, в нем можно указать произвольный URL 
	aJSON := TRESTLight.Execute2(aUploadURL, FVKApp, aFields);

      TThread.Synchronize(TThread.CurrentThread,
        procedure
        begin
          Memo1.Lines.Add('---- upload file to server ----');
          Memo1.Lines.Add(aJSON);
        end);
    end);

fmx.restlight's People

Contributors

rzaripov1990 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.