点击这里给我发消息
帮助中心

工作时间:8:30 - 17:30

DELPHI

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IdHTTP, IdURI, Httpapp, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    function httpPost(postUrl:String;Params:TStrings):string;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  url : string;
  username : string;
  password,apikey,mobile,content,encode,str : string;
  Params:   TStrings;
  i :Integer;
begin
  //实例:http://sms.106jiekou.com/utf8/sms.aspx?account=用户账号&password=接口密码&mobile=号码&content=您的订单编码:888888。如需帮助请联系客服。
  Params   :=   TStringList.Create;
  username := ''; //用户名 
  password := ''; //接口密码
  mobile :=''; //手机号,只发一个号码:158xxxxxxxx。
  content := UTF8Encode('您的订单编码:7231。如需帮助请联系客服。'); //要发送的短信内容,特别注意:签名必须设置,网页验证码应用需要加添加【图形识别码】以防被短信攻击
  //ShowMessage(content);
  Params.Add('account='+username) ;
  Params.Add('password='+password) ;
  Params.Add('mobile='+mobile) ;
  Params.Add('content='+content) ;
  url := 'http://sms.106jiekou.com/utf8/sms.aspx?';
  ShowMessage(httpPost(url,Params));  //要发送的URL链接与内容。
  Params.Free;
end;
function  TForm1.httpPost(postUrl:string;Params:TStrings):string;
var
  idhtp1: TIdHTTP;
begin
  idhtp1:=   TidHTTp.create(self);
  idhtp1.AllowCookies:=True;
  idhtp1.HTTPOptions:=[hoForceEncodeParams];
  idhtp1.ProtocolVersion:=pv1_1;
  idhtp1.Request.ContentType:='application/x-www-form-urlencoded';
  idhtp1.Request.CacheControl:='no-cache';
  idhtp1.Request.UserAgent:='User-Agent=Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1';
  idhtp1.Request.Accept:='Accept=textml,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
  idhtp1.Request.AcceptEncoding:='Accept-Encoding=gzip,deflate';
  idhtp1.Request.AcceptCharSet:='Accept-Charset=gb2312,utf-8;q=0.7,*;q=0.7';
  idhtp1.Request.Connection:='Connection=keep-alive';
  try
    result := idhtp1.Post(postUrl,Params);
  except
    Result := 'error';
end;
end;

end.