吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 5934|回复: 14
收起左侧

[其他转载] 自写的某短信平台的类。需要的自取

[复制链接]
CCStation 发表于 2017-11-14 23:27
说明见图片
[Delphi] 纯文本查看 复制代码
unit SMS;    //速码平台

interface

type
  TSMS = class
  private
    Ftoken: string;
    Fpwd: string;
    Fuid: string;
    Fremain: string;
    Fjifen: string;
    FErrorNum: string;
    FphoneNum: string;
    procedure Settoken(const Value: string);
    procedure Setpwd(const Value: string);
    procedure Setuid(const Value: string);
    procedure Setremain(const Value: string);
    procedure Setjifen(const Value: string);
    function Readjifen: string;
    function Readremain: string;
    procedure SetErrorNum(const Value: string);
  public
    property uid: string read Fuid write Setuid;
    property pwd: string read Fpwd write Setpwd;
    property token: string read Ftoken write Settoken;
    property jifen: string read Readjifen write Setjifen;
    property remain: string read Readremain write Setremain;
    property ErrorNum: string read FErrorNum write SetErrorNum;
    constructor Create(uid: string; pwd: string);
    destructor Destroy; override;
    function getUserInfos: string;
    function getMobilenum(pid: Integer; mobile: string; province: string; phoneType: string): string; overload;
    function getMobilenum(pid: Integer): string; overload;
    function getVcodeAndReleaseMobile(size: Integer): string;
  end;

implementation

uses
  IdHTTP, System.Classes, System.SysUtils, System.RegularExpressions, Winapi.Windows,
  Vcl.Forms;

var
  http: TIdHTTP;
  x: Integer;

const
  url = 'http://api.eobzz.com/httpApi.do?action=';
{ TSMS }


function HaveSigned(MaxWaitTime: Cardinal): Boolean;
var
  I: Integer;
var
  WaitedTime: Cardinal;
begin
  WaitedTime := 0;
  while (WaitedTime < MaxWaitTime) do
  begin
    SleepEx(100, False);
    Inc(WaitedTime, 100);
    Application.ProcessMessages;
  end
end;

function TSMS.getMobilenum(pid: Integer; mobile: string; province, phoneType: string): string;
var
  ss: TStringStream;
begin
  x := 12;
  ss := TStringStream.Create('', TEncoding.UTF8);
  http.Get(url + 'getMobilenum&pid=' + IntToStr(pid) + '&uid=' + Fuid + '&token=' + Ftoken + '&mobile=' + mobile + '&size=1&province=' + province + '&phoneType=' + phoneType, ss);
  Result := TRegEx.Match(ss.DataString, '\d{11}').Value;
  FphoneNum := Result;
  ss.Free;
end;

function TSMS.getMobilenum(pid: Integer): string;
var
  ss: TStringStream;
begin
  x := 12;
  ss := TStringStream.Create('', TEncoding.UTF8);
  http.Get(url + 'getMobilenum&pid=' + IntToStr(pid) + '&uid=' + Fuid + '&token=' + Ftoken, ss);
  Result := TRegEx.Match(ss.DataString, '\d{11}').Value;
  FphoneNum := Result;
  ss.Free;
end;

function TSMS.getVcodeAndReleaseMobile(size: Integer): string;
var
  ss: TStringStream;
  pattern: string;
  arr: TArray<string>;
begin
  Result := '';
  pattern := '\d{' + inttostr(size) + '}';
  ss := TStringStream.Create('', TEncoding.UTF8);
  http.Get(url + 'getVcodeAndReleaseMobile&uid=' + Fuid + '&token=' + Ftoken + '&mobile=' + FphoneNum + '&author_uid=18252467187', ss);
  if ss.DataString = 'not_receive' then
  begin
    HaveSigned(5000);
    OutputDebugString(PChar(ss.DataString));
    Result := getVcodeAndReleaseMobile(size);

  end
  else
  begin
    if TRegEx.IsMatch(ss.DataString, FphoneNum) then
    begin
      arr := TRegEx.Split(ss.DataString, '\|');
      Result := TRegEx.Match(arr[1], pattern).Value;
    end
    else
    begin
      Result := ss.DataString;
    end;
  end;
  ss.Free;
end;

function TSMS.getUserInfos: string;
var
  ss: TStringStream;
  arr: TArray<string>;
begin
  ss := TStringStream.Create('', TEncoding.UTF8);
  http.Get(url + 'getUserInfos&uid=' + Fuid + '&token=' + Ftoken, ss);
  if TRegEx.IsMatch(ss.DataString, Fuid) then
  begin
    arr := TRegEx.Split(ss.DataString, ';');
    Fremain := arr[2];
    Fjifen := arr[1];
  end
  else
  begin
    ErrorNum := ss.DataString;
  end;

  ss.Free
end;

function TSMS.Readjifen: string;
begin
  getUserInfos;
  Result := Fjifen;
end;

function TSMS.Readremain: string;
begin
  getUserInfos;
  Result := Fremain;
end;

procedure TSMS.SetErrorNum(const Value: string);
begin
  FErrorNum := Value;
end;

procedure TSMS.Setjifen(const Value: string);
begin
  Fjifen := Value;
end;

procedure TSMS.Setpwd(const Value: string);
begin
  Fpwd := Value;
end;

procedure TSMS.Setremain(const Value: string);
begin
  Fremain := Value;
end;

procedure TSMS.Settoken(const Value: string);
begin
  Ftoken := Value;
end;

procedure TSMS.Setuid(const Value: string);
begin
  Fuid := Value;
end;

constructor TSMS.Create(uid: string; pwd: string);
var
  ss: TStringStream;
  Arr: TArray<string>;
begin
  ss := TStringStream.Create('', tencoding.utf8);
  Fuid := uid;
  Fpwd := pwd;
  http := TIdHTTP.Create();
  http.Get(url + 'loginIn&uid=' + Fuid + '&pwd=' + Fpwd, ss);
  if TRegEx.IsMatch(ss.DataString, Fuid) then
  begin
    Arr := TRegEx.Split(ss.DataString, '\|');
    token := Arr[1];
  end
  else
  begin
    token := '';
  end;
  ss.Free;
end;

destructor TSMS.Destroy;
begin
  http.Free;
  inherited;
end;

end.

使用说明

使用说明

免费评分

参与人数 1吾爱币 +1 热心值 +1 收起 理由
Ashes + 1 + 1 热心回复!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| CCStation 发表于 2017-11-14 23:29
欢迎大神指正不足,小众的delphi 好像没什么人了
cck 发表于 2017-11-14 23:42
532329063 发表于 2017-11-14 23:57
sherry5566 发表于 2017-11-15 00:44
谢谢分享
sw0rdman 发表于 2017-11-15 01:14
已弃delphi 7 使用免费开源Lazarus
ywq5203 发表于 2017-11-15 02:35
刚花钱弄的手机注册账号 收短信
li6893 发表于 2017-11-15 03:13
谢谢分享
大九丶 发表于 2017-11-15 03:43
谢谢分享
火菩萨 发表于 2017-11-15 06:47
谢谢分享
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-15 08:25

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表