介面都是通過HTTP訪問,從服務器請求資料,提交資料。
發送訊息介面
訪問地址:Http://ceshi.com
訪問類別 POST
引數 title: 發送訊息的標題
description: 發送資訊的詳細資訊
示例 Http://ceshi.com
引數為:{
title:”您的申請已經獲得批準”,
description:”您申請了會員資格,已經被相關部門審批通過”
}
結果為JSON格式 {"code":0}
請問這個要怎么在delphi中實作啊,求原始碼!
uj5u.com熱心網友回復:
IdHttp不行么uj5u.com熱心網友回復:
我有封裝了個http post 和get,直接就可以用,引數就是key value結構class function TSMSystem.GetResponseContent(const http: TIdHTTP; url: string;
encode: TEncoding=nil; param: TStrings=nil): string;
var
response: TStringStream;
begin
result := '';
if encode=nil then response := TStringStream.Create('')
else response := TStringStream.Create('',encode);
try
if param=nil then
begin
http.Get(url,response);
end
else begin
http.Post(url,param,response);
end;
result := response.DataString;
except
end;
response.Free;
end;
非key value 的,用這個
class function TSMSystem.GetResponseContentEx(const http: TIdHTTP; url: string;
encode: TEncoding=nil; param: TStringStream=nil): string;
var
response: TStringStream;
begin
result := '';
if encode=nil then
response := TStringStream.Create('')
else
response := TStringStream.Create('',encode);
try
if param=nil then
begin
http.Get(url,response);
end
else begin
http.Post(url,param,response);
end;
result := response.DataString;
except
end;
response.Free;
end;
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/67834.html
標籤:語言基礎/算法/系統設計
