您的位置:首页 > Web前端

asp.net使用飞信fetionAPI接口免费发送短信的c#的实例

2010-08-07 02:39 846 查看
飞信免费发短信API接口调用方式(通过HTTP访问以下网址、支持GET和POST):(可用)


http://sms.api.bz/fetion.php?username=您的移动飞信登录手机号&password=您的移动飞信登录密码&sendto=接收短信的飞信好友手机号(也可以是你自己的手机号)&message=短信内容


注:短信内容最大长度为180个汉字,超过180个汉字不发送。返回的信息为UTF-8编码的中文文本信息。

2009年5月28日新增:飞信免费发短信API接口调用方式(通过HTTPS加密隧道访问以下网址、支持GET和POST,进一步保证您的密码安全):

下面的这条 我测试失败 根据验证过程,远程证书无效 大概是和https有关


https://sms.api.bz/fetion.php?username=您的移动飞信登录手机号&password=您的移动飞信登录密码&sendto=接收短信的飞信好友手机号(也可以是你自己的手机号)&message=短信内容


注:短信内容最大长度为180个汉字,超过180个汉字不发送。返回的信息为UTF-8编码的中文文本信息。

发送实例:C# CODE:


aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default"%>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN" “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>短信发送</title>

</head>
<body>
<form runat="server" id="form1">
<div style="height: 251px; width: 464px; font-size:12px;">
<font color="#ff6600">飞信免费发短信API接口调用方式(通过HTTP访问以下网址、支持GET和POST):</font><br />
<table style="width:100%;">
<tr>
<td class="style1">
您的手机/飞信号码</td>
<td>
<asp:TextBox ID="telFrom" runat="server" Width="203px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style1">
您的飞信登陆密码</td>
<td>
<asp:TextBox ID="telPwd" runat="server" TextMode="Password" Width="203px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style1">
接收信息的手机号码</td>
<td>
<asp:TextBox ID="toTel" runat="server" Width="203px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style1">
短信内容(最多180汉字)</td>
<td>
<asp:TextBox ID="content" runat="server" Text ="短信内容" Height="144px" Width="215px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style1">
<asp:Button ID="send" runat="server" Text="发送短信" OnClick="send_Click"
/>
</td>
<td>
 </td>
</tr>
</table>
</div>
</form>
</body>
</html>

cs:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Net;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{

protected void send_Click(object sender, EventArgs e)
{
string fromNum = telFrom.Text; //发送的手机号

string pwd = telPwd.Text; //手机密码

string toNum = toTel.Text; //接收的手机号码

string contents = content.Text; //注意 这下面是 http协议 而没有用https 会报 根据验证过程,远程证书无效 的错误

string url = "http://sms.api.bz/fetion.php?username="+fromNum+"&password="+pwd+"&sendto=" + toNum + "&message=" + contents + "";

HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);

req.Method = "GET";

using (WebResponse wr = req.GetResponse())
{
Response.Write("短信发送成功!");
}
}
}



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐