代码实例
$post_data['userid'] = ID;
$post_data['account'] = '账号';
$post_data['password'] = '密码';
$post_data['content'] = '短信内容';
//多个手机号码用英文半角豆号‘,’分隔
$post_data['mobile'] = '130xxxxxxxx,131xxxxxxxx';
$url='http://www.qf106.com/sms.aspx?action=send';
$o='';
foreach ($post_data as $k=>$v)
{
//短信内容需要用urlencode编码,否则可能收到乱码
$o.="$k=".urlencode($v).'&';
}
$post_data=substr($o,0,-1);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //如果需要将结果直接返回到变量里,那加上这句。
$result = curl_exec($ch);
?>
接口文件下载点击这里:
public class SmsClientSend {
/*
* @param url
* :必填--发送连接地址URL——http://www.qf106.com/sms.aspx
* @param userid
* :必填--用户ID,为数字
* @param account
* :必填--用户帐号
* @param password
* :必填--用户密码
* @param mobile
* :必填--发送的手机号码,多个可以用逗号隔比如>130xxxxxxxx,131xxxxxxxx
* @param content
* :必填--实际发送内容,
* @param action
* :选填--访问的事件,默认为send
* @param sendType
* :选填--发送方式,默认为POST
* @param codingType
* :选填--发送内容编码方式,默认为UTF-8
* @param backEncodType
* :选填--返回内容编码方式,默认为UTF-8
* @return 返回发送之后收到的信息
*/
private static String sendSms(String url, String userid, String account,
String password, String mobile, String content, String action,
String sendType, String codingType, String backEncodType) {

try {
if (codingType == null || codingType.equals("")) {
codingType = "UTF-8";
}
if (backEncodType == null || backEncodType.equals("")) {
backEncodType = "UTF-8";
}
StringBuffer send = new StringBuffer();
if (action != null && !action.equals("")) {
send.append("action=").append(action);
} else {
send.append("action=send");
}

send.append("&userid=").append(userid);
send.append("&account=").append(
URLEncoder.encode(account, codingType));
send.append("&password=").append(
URLEncoder.encode(password, codingType));
send.append("&mobile=").append(mobile);
send.append("&content=").append(
URLEncoder.encode(content, codingType));
if (sendType != null && (sendType.toLowerCase()).equals("get")) {
return SmsClientAccessTool.getInstance().doAccessHTTPGet(
url + "?" + send.toString(), backEncodType);
} else {
return SmsClientAccessTool.getInstance().doAccessHTTPPost(url,
send.toString(), backEncodType);
}
} catch (Exception e) {
e.printStackTrace();
return "未发送,编码异常";
}
}

}
public class SmsClientAccessTool {

private static SmsClientAccessTool smsClientToolInstance;

/**
* 采用单列方式来访问操作
*
* @return
*/
public static synchronized SmsClientAccessTool getInstance() {

if (smsClientToolInstance == null) {
smsClientToolInstance = new SmsClientAccessTool();
}
return smsClientToolInstance;
}

/**
*


* POST方法
*


*
* @param sendUrl
* :访问URL
* @param paramStr
* :参数串
* @param backEncodType
* :返回的编码
* @return
*/
public String doAccessHTTPPost(String sendUrl, String sendParam,
String backEncodType) {

StringBuffer receive = new StringBuffer();
BufferedWriter wr = null;
try {
if (backEncodType == null || backEncodType.equals("")) {
backEncodType = "UTF-8";
}

URL url = new URL(sendUrl);
HttpURLConnection URLConn = (HttpURLConnection) url
.openConnection();

URLConn.setDoOutput(true);
URLConn.setDoInput(true);
((HttpURLConnection) URLConn).setRequestMethod("POST");
URLConn.setUseCaches(false);
URLConn.setAllowUserInteraction(true);
HttpURLConnection.setFollowRedirects(true);
URLConn.setInstanceFollowRedirects(true);

URLConn.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded;charset=UTF-8");
URLConn.setRequestProperty("Content-Length", String
.valueOf(sendParam.getBytes().length));

DataOutputStream dos = new DataOutputStream(URLConn
.getOutputStream());
dos.writeBytes(sendParam);

BufferedReader rd = new BufferedReader(new InputStreamReader(
URLConn.getInputStream(), backEncodType));
String line;
while ((line = rd.readLine()) != null) {
receive.append(line).append("\r\n");
}
rd.close();
} catch (java.io.IOException e) {
receive.append("访问产生了异常-->").append(e.getMessage());
e.printStackTrace();
} finally {
if (wr != null) {
try {
wr.close();
} catch (IOException ex) {
ex.printStackTrace();
}
wr = null;
}
}

return receive.toString();
}

public String doAccessHTTPGet(String sendUrl, String backEncodType) {

StringBuffer receive = new StringBuffer();
BufferedReader in = null;
try {
if (backEncodType == null || backEncodType.equals("")) {
backEncodType = "UTF-8";
}

URL url = new URL(sendUrl);
HttpURLConnection URLConn = (HttpURLConnection) url
.openConnection();

URLConn.setDoInput(true);
URLConn.setDoOutput(true);
URLConn.connect();
URLConn.getOutputStream().flush();
in = new BufferedReader(new InputStreamReader(URLConn
.getInputStream(), backEncodType));

String line;
while ((line = in.readLine()) != null) {
receive.append(line).append("\r\n");
}

} catch (IOException e) {
receive.append("访问产生了异常-->").append(e.getMessage());
e.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (java.io.IOException ex) {
ex.printStackTrace();
}
in = null;

}
}

return receive.toString();
}
}
接口文件下载点击这里:
public string send_sms()
{
string str_userid = "ID";
string str_account = "账号";
string str_password = "密码";
string str_content = "内容";
string str_mobile = "手机号码";//130xxxxxxxx,131xxxxxxxx多个号码用英文半角‘,’分隔

string param = string.Format(@"action=send&userid={0}&account={1}&password={2}&content={3}&mobile={4}", str_userid, str_account, str_password, str_content, str_mobile);
string url = "http://www.qf106.com/sms.aspx";
Response.Write(PostSend(url, param));//输出返回值
}

private string PostSend(string url, string postdate)
{
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
myHttpWebRequest.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
myHttpWebRequest.Method = "POST";
Stream myRequestStream = myHttpWebRequest.GetRequestStream();
StreamWriter myStreamWriter = new StreamWriter(myRequestStream);
myStreamWriter.Write(postdate);
myStreamWriter.Flush();
myStreamWriter.Close();
myRequestStream.Close();

HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
Stream myResponseStream = myHttpWebResponse.GetResponseStream();
StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
String outdata = myStreamReader.ReadToEnd();
myStreamReader.Close();
myResponseStream.Close();
return outdata;
}
接口文件下载点击这里:
Public Class WebForm1
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Dim web As New System.Net.WebClient() '验证帐号
web.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
Dim d As Byte() = System.Text.Encoding.UTF8.GetBytes("userid=你的ID&password=你的密码&account=你的账号")
Dim res As Byte() = web.UploadData("http://www.qf106.com/sms.aspx?action=checkkeyword", "POST", d)
Dim str_res As String
str_res = System.Text.Encoding.GetEncoding("utf-8").GetString(res)
Response.Write(str_res)
End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
Dim web As New System.Net.WebClient() '余额查询
web.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
Dim d As Byte() = System.Text.Encoding.UTF8.GetBytes("userid=你的ID&password=你的密码&account=你的账号")
Dim res As Byte() = web.UploadData("http://www.qf106.com/sms.aspx?action=overage", "POST", d)
Dim str_res As String
str_res = System.Text.Encoding.GetEncoding("utf-8").GetString(res)
Response.Write(str_res)
End Sub

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button3.Click
Dim web As New System.Net.WebClient() '发送短信
web.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
Dim d As Byte()
d = System.Text.Encoding.UTF8.GetBytes("userid=你的ID&password=你的密码&account=你的账号&content=" + TextBox3.Text + "&mobile=" + TextBox2.Text)
Dim res As Byte() = web.UploadData("http://www.qf106.com/sms.aspx?action=send", "POST", d)
Dim str_res As String
str_res = System.Text.Encoding.GetEncoding("utf-8").GetString(res)
Response.Write(str_res)
End Sub
End Class
接口文件下载点击这里:
set xmlhttp=Server.CreateObject("MSXML2.XMLHTTP")
URL="http://www.qf106.com/sms.aspx?action=send&userid=&account=账号&password=密码&mobile=号码&content=内容"
xmlhttp.open "POST",URL, False
xmlhttp.send
if xmlhttp.readyState = 4 then
Set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.loadXML(xmlhttp.responseText)
Set item=xmlDoc.getElementsByTagName("returnsms")
For i=0 To (item.Length-1)
Set returnstatus=item.Item(i).getElementsByTagName("returnstatus")
Set message=item.Item(i).getElementsByTagName("message")
Response.Write returnstatus.Item(0).Text
Response.Write message.Item(0).Text

Next
end if
end if
接口文件下载点击这里:
unit frmMainUnit;
interface

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

type
TfrmMain = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
CheckBox1: TCheckBox;
DateTimePicker1: TDateTimePicker;
DateTimePicker2: TDateTimePicker;
Label1: TLabel;
Label2: TLabel;
Memo1: TMemo;
Edit1: TEdit;
Label3: TLabel;
Edit2: TEdit;
Label4: TLabel;
IdHTTP1: TIdHTTP;
StaticText1: TStaticText;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
frmMain : TfrmMain;

implementation

{$R *.dfm}
uses httpapp;

procedure TfrmMain.Button1Click(Sender: TObject);
var
vParam : TStringList;
begin //验证帐号
vParam := TStringList.Create;
try
vParam.Add('userid=你的ID');
vParam.Add('password=你的密码');
vParam.Add('account=你的账号');
IdHTTP1.Request.AcceptCharSet := 'GBK';
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
Edit2.Text := IdHTTP1.Post('http://www.qf106.com/smsGBK.aspx', vParam);
finally
vParam.Free;
end;
end;

procedure TfrmMain.Button2Click(Sender: TObject);
var
vParam : TStringList;
begin //查询余额
vParam := TStringList.Create;
try
vParam.Add('userid=你的ID');
vParam.Add('password=你的密码');
vParam.Add('account=你的账号');
IdHTTP1.Request.AcceptCharSet := 'GBK';
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
Edit2.Text := IdHTTP1.Post('http://www.qf106.com/smsGBK.aspx', vParam);
finally
vParam.Free;
end;
end;

procedure TfrmMain.Button3Click(Sender: TObject);
var
vParam : TStringList;
begin //发送短信
vParam := TStringList.Create;
try
vParam.Add('userid=你的ID');
vParam.Add('password=你的密码');
vParam.Add('account=你的账号');
vParam.Add('content=' + HTTPEncode(Memo1.Lines.Text));
vParam.Add('mobile=' + HTTPEncode(Edit1.Text));
IdHTTP1.Request.AcceptCharSet := 'GBK';
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
Edit2.Text := IdHTTP1.Post('http://www.qf106.com/smsGBK.aspx', vParam);
finally
vParam.Free;
end;
end;

procedure TfrmMain.FormCreate(Sender: TObject);
begin
DateTimePicker1.DateTime := now;
DateTimePicker2.DateTime := now;
end;
end.
import urllib urllib2

url="http://www.qf106.com/sms.aspx"

data['action'] = 'send'
data['userid'] = '你的ID'
data['account'] = '你的账号'
data['password'] = '你的密码'
data['mobile'] = '手机号码'
data['content'] = '短信内容'

post_data = urllib.urlencode(data)
req = urllib2.urlopen(url, post_data)
content = req.read()
    var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?3f008b7001f51dfd594989fc4e3e4a57"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })();