Flex使用ribbit.com的服务给手机发送短信SMS
2009-06-13 15:10
357 查看
http://www.ribbit.com/
可以将语音通信和丰富的功能集成到您的网站,应用或社区。
这里说一下使用 ribbit.com 的服务免费给手机发短信。(目前只支持美国手机号)
1. 访问 www.ribbit.com 注册并下载 Flex 的类库 RibbitAPI_2.5.0.1070_FX3_CS4.swc
2. 创建Flex项目,并引入下载的RibbitAPI_2.5.0.1070_FX3_CS4.swc
3. 要免费使用www.ribbit.com的服务,需要以下信息, 大部分在My Profile中能看到
- user id: 就是登录名,通常是一个邮箱
- password: 登录的密码
- developer id: My Profile面板中Developer ID的值
- application id: 点击My Apps -> Start an App, 注册你的app项目,App URL可以填写你自己GAE site的地址。注册成功后就能看到App ID了,通常是用户名和项目名的组合。
4. 下面是代码
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:ribbit="com.ribbit.api.*" width="346" height="244" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#BFE4EF, #B3BCCF]" creationComplete="init()"> <mx:Script> [CDATA[ import mx.controls.Alert; import mx.messaging.channels.StreamingAMFChannel; import com.ribbit.api.interfaces.IMessageManager; import com.ribbit.api.interfaces.IAuthenticationManager; import com.ribbit.api.events.MessageEvent; import com.ribbit.api.events.AuthenticationEvent; import com.ribbit.api.objects.LoginParam; private static const userid : String = "Your User ID"; private static const password : String = "Your Password"; private static const devHandle : String = "Your Developer ID"; private static const applicationId : String = "Your App ID"; private var loginObject:LoginParam; public function init():void{ request.authenticationManager.addEventListener(AuthenticationEvent.LOGGING_IN, handleAuthEvent); request.authenticationManager.addEventListener(AuthenticationEvent.LOGGED_IN, handleAuthEvent); request.authenticationManager.addEventListener(AuthenticationEvent.LOGGED_OUT, handleAuthEvent); request.authenticationManager.addEventListener(AuthenticationEvent.ERROR, authError); request.addEventListener(MessageEvent.MESSAGE_SENT, handleMessageSent); // login request.login(userid, password, devHandle, applicationId, loginObject); initEventListeners(); } private function initEventListeners():void{ smsSubmit.addEventListener(MouseEvent.CLICK, retrieveTextInfo); } private function retrieveTextInfo(event:MouseEvent):void{ //原文作者在这里有个小错误,他将message和subject的参数位置写颠倒了 sendSMS(cellNumber.text, message.text, subject.text); } private function sendSMS(mobileNumber:String, message:String, subject:String=""):void{ request.messageManager.sendSmsMessage(mobileNumber, message, subject); } private function handleAuthEvent(event:AuthenticationEvent):void{ switch(event.type){ case AuthenticationEvent.LOGGED_IN: loginStatus.text = "Logged In OK!"; smsSubmit.enabled = true; break; case AuthenticationEvent.LOGGING_IN: loginStatus.text = "Logging In..."; break; } } private function handleMessageSent(event:MessageEvent):void{ Alert.show("Message has been sent"); } private function authError(event:AuthenticationEvent):void{ loginStatus.text = "Login Error"; Alert.show("Auth Error:" + event.data); } ]] </mx:Script> <ribbit:RibbitServices id="request"/> <mx:Label x="21" y="16" text="Cell Number" fontSize="12"/> <mx:TextInput id="cellNumber" x="110" y="16" width="221"/> <mx:Label x="20" y="44" text="SMS Subject" fontSize="12"/> <mx:TextInput id="subject" x="110" y="44" width="221"/> <mx:Label x="16" y="72" text="SMS Content" fontSize="12"/> <mx:TextArea id="message" x="110" y="73" width="221" height="124"/> <mx:Button id="smsSubmit" x="110" y="205" label="Send SMS" enabled="false"/> <mx:Label id="loginStatus" x="198" y="207" width="133" textAlign="right"/> </mx:Application>
经过测试确实可以给美国手机发短信(T-Mobile的号码)
短信内容一般为 rabbit@rabbit.com / subject / content
阅读更多
相关文章推荐
- C# 使用SMS接口实现手机短信发送功能
- linux 下使用短信 api 给自己发送手机短信
- 使用.net开发手机管理软件 (十二) 短信部分——通过RS232发送和接收短信
- 用Delphi发送SMS(手机短消息服务)
- 用 Java 通过串口发送手机短信(二)简单使用
- Android使用Intent发送短信SMS
- 基于SMS短信平台给手机发送短信
- 阿里云的云通信短信服务--发送验证码到手机
- C# Windows服务 定时执行访问数据库循环发送手机短信
- Android监听SMS发送状态并获取短信服务中心号码
- 基于Windows Azure 搭建基于SharePoint 2010 Intranet、Extranet、Internet (4): 配置传出邮件服务: 使用 outlook.com 发送邮件通知
- 使用NowSMS Gateway来接收发送短信和彩信
- Android 使用ContentObserver监听短信的变化,并发送信息给特定的手机号码
- 在电脑上使用AT命令通过手机发送短信
- 使用阿里云消息服务mns发送短信
- java使用短信设备发送sms短信的示例(java发送短信)
- 转载 : 一个Windows后台服务(.Net的C#版) - 定时访问数据库循环发送手机短信
- 使用Qt Mobility实现手机短信的发送功能
- WinCE 使用RIL发送短信SMS(类似sms.dll)
- SMS短信通API——(1)Java应用发送手机短信