[文章作者:张宴 本文版本:v1.0 最后修改:2009.03.22 转载请注明原文链接:http://blog.s135.com/fetion_api/
]
飞信
是由中国移动通信集团公司推出的一款集商务应用和娱乐功能为一体的,基于手机应用以及与Internet深度互通的即时通讯产品,可免费给好友发送短信。
1、下载中国移动飞信PC客户端软件(http://www.fetion.com.cn/downloads/pc.aspx
),并注册开通飞信。注册成为飞信用户,下载飞信PC客户端、使用PC客户端基本功能,不收取费用。
2、通过PC客户端,邀请并添加免费短信接收方的手机号码(仅限中国移动)到您的飞信好友,该手机号需要通过通过PC客户端、或回复短信接受您的邀请;
3、通过 http://sms.api.bz/
提供的 API 接口,即可免费给飞信好友发短信。利用本API接口可进行日程提醒、服务器监控、报警、故障通知或短信自动控制等功能。
飞信免费发短信API接口在线演示:
http://sms.api.bz/
飞信免费发短信API接口调用方式(通过HTTP访问以下网址、支持GET和POST):
注:短信内容最大长度为180个汉字,超过180个汉字不发送。返回的信息为UTF-8编码的中文文本信息。
例1:在Linux命令行下通过curl命令给自己的手机号(假设为13800138000)发送短信
curl "http://sms.api.bz/fetion.php?username=13800138000&password=123456&sendto=13800138000&message=短信内容"
例2:在PHP5中通过file_get_contents函数发送短信(HTTP GET 方式)
-
<?php
-
$url
=
"http://sms.api.bz/fetion.php?username=13812345678&password=123456&sendto=13512345678&message=短信内容"
;
-
$result
=
file_get_contents
(
$url
);
-
echo
$result
;
-
-
?>
例3:在PHP中通过curl发送短信(HTTP POST 方式)
-
<?php
-
$data
[
"username"
] = 13812345678;
-
$data
[
"password"
] =
"password123"
;
-
$data
[
"sendto"
] = 13512345678;
-
$data
[
"message"
] =
"这是一条测试短信!"
;
-
-
$curl
=
new
Curl_Class();
-
$result
= @
$curl
->post(
"http://sms.api.bz/fetion.php"
,
$data
);
-
echo
$result
;
-
-
-
-
class
Curl_Class
-
{
-
function
Curl_Class()
-
{
-
return
true;
-
}
-
-
function
execute(
$method
,
$url
,
$fields
=
''
,
$userAgent
=
''
,
$httpHeaders
=
''
,
$username
=
''
,
$password
=
''
)
-
{
-
$ch
= Curl_Class::create();
-
if
(false ===
$ch
)
-
{
-
return
false;
-
}
-
-
if
(
is_string
(
$url
) &&
strlen
(
$url
))
-
{
-
$ret
= curl_setopt(
$ch
, CURLOPT_URL,
$url
);
-
}
-
else
-
{
-
return
false;
-
}
-
-
curl_setopt(
$ch
, CURLOPT_HEADER, false);
-
-
curl_setopt(
$ch
, CURLOPT_RETURNTRANSFER, true);
-
-
if
(
$username
!=
''
)
-
{
-
curl_setopt(
$ch
, CURLOPT_USERPWD,
$username
.
':'
.
$password
);
-
}
-
-
$method
=
strtolower
(
$method
);
-
if
(
'post'
==
$method
)
-
{
-
curl_setopt(
$ch
, CURLOPT_POST, true);
-
if
(
is_array
(
$fields
))
-
{
-
$sets
=
array
();
-
foreach
(
$fields
AS
$key
=>
$val
)
-
{
-
$sets
[] =
$key
.
'='
. urlencode(
$val
);
-
}
-
$fields
= implode(
'&'
,
$sets
);
-
}
-
curl_setopt(
$ch
, CURLOPT_POSTFIELDS,
$fields
);
-
}
-
else
if
(
'put'
==
$method
)
-
{
-
curl_setopt(
$ch
, CURLOPT_PUT, true);
-
}
-
-
-
-
-
curl_setopt(
$ch
, CURLOPT_TIMEOUT, 10);
-
-
if
(
strlen
(
$userAgent
))
-
{
-
curl_setopt(
$ch
, CURLOPT_USERAGENT,
$userAgent
);
-
}
-
-
if
(
is_array
(
$httpHeaders
))
-
{
-
curl_setopt(
$ch
, CURLOPT_HTTPHEADER,
$httpHeaders
);
-
}
-
-
$ret
= curl_exec(
$ch
);
-
-
if
(curl_errno(
$ch
))
-
{
-
curl_close(
$ch
);
-
return
array
(curl_error(
$ch
), curl_errno(
$ch
));
-
}
-
else
-
{
-
curl_close(
$ch
);
-
if
(!
is_string
(
$ret
) || !
strlen
(
$ret
))
-
{
-
return
false;
-
}
-
return
$ret
;
-
}
-
}
-
-
function
post(
$url
,
$fields
,
$userAgent
=
''
,
$httpHeaders
=
''
,
$username
=
''
,
$password
=
''
)
-
{
-
$ret
= Curl_Class::execute(
'POST'
,
$url
,
$fields
,
$userAgent
,
$httpHeaders
,
$username
,
$password
);
-
if
(false ===
$ret
)
-
{
-
return
false;
-
}
-
-
if
(
is_array
(
$ret
))
-
{
-
return
false;
-
}
-
return
$ret
;
-
}
-
-
function
get(
$url
,
$userAgent
=
''
,
$httpHeaders
=
''
,
$username
=
''
,
$password
=
''
)
-
{
-
$ret
= Curl_Class::execute(
'GET'
,
$url
,
''
,
$userAgent
,
$httpHeaders
,
$username
,
$password
);
-
if
(false ===
$ret
)
-
{
-
return
false;
-
}
-
-
if
(
is_array
(
$ret
))
-
{
-
return
false;
-
}
-
return
$ret
;
-
}
-
-
function
create()
-
{
-
$ch
= null;
-
if
(!function_exists(
'curl_init'
))
-
{
-
return
false;
-
}
-
$ch
= curl_init();
-
if
(!
is_resource
(
$ch
))
-
{
-
return
false;
-
}
-
return
$ch
;
-
}
-
-
}
-
?>
分享到:
相关推荐
利用中国移动飞信API免费发短信程序源码,适合做监控报警提示!
VB模拟中国移动飞信发手机短信,这是早几年前写的,现在可能因为里面的WEB接口失效而不能发短信了,这个不影响研究原理,你或者查找一个飞信接口修正一下代码。
1.此程序运行在XP上需要安装 Microsoft .NET Framework 2.0 或以上 , Windows 7/Vista可以不安装Microsoft .NET Framework ... 2.免费给全球任何移动电话发短信。...免费短信任我发 用C#和第三方接口制作
免费注册,免费短信,多终端登陆永不离线,语音群聊超低资费
使用飞信 VCL 能够方便的开发中国移动飞信第三方客户端,飞信 VCL 屏蔽了底层的通信协议,为开发者提供简单,丰富的上层应用接口,使得开发者能够轻松的几行代码就能开发出属于自己平台的飞信第三方客户端。用飞信 ...
1.此程序运行在XP上...3.小程序用C#和第三方接口制作。欢迎学习交流,提供源码。没有技术含量,请所谓的高手绕行。 Email:heihei5413@163.com 济南惠子家教网 欢迎您, 家教辅导,我们更专业 http://www.huizijj.com
移动飞信发送短信的开发接口ActiveX,可用于各类语言。
移动短信开发接口 java .net php
亿美短信应用API接口-八项创新 1、全网覆盖:全国全网、电信、联通、移动显示同一号码 2、心跳机制:保证客户端与服务器时时连接 3、异步通讯:支持异步通讯,每个连接峰值可达20条/秒 4、智能化短信...
移动代理服务器MAS短信API2.2开发手册及问题列表及DEMO,包括ASP,VB,JAVA,C/C++,PB,DELPHI,.NET等
中国移动集团政企云MAS平台短信SDK接口文档,含文档,java 和 .net的sdk及其依赖包。
为了怕玩的人多了,移动服务器发现,请大家测试自己的手机玩,尽量少发 无奈啊.......... 欢迎 http://topic.csdn.net/u/20090327/22/5ed56ec5-69f2-4db2-abde-e30fbb950ab0.html 拍砖..... 这次弄点分,以后好下...
怎样借用移动飞信发免费手机短信 移动飞信协议分析与接口调用资料整理
中国移动短信接口API.函数(COM、DLL 、Java)
中国移动集团政企云MAS平台短信SDK接口文档.zip
飞信2008,能免费发短信,是建立在移动公司移动交友的功能之下
移动飞信免费发短信。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
短信群发 短信接口 说明 中国移动集团短信接口说明.doc
移动代理服务器MAS短信API2.2开发手册(.Net)