600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > Flex使用ribbit.com的服务给手机发送短信SMS

Flex使用ribbit.com的服务给手机发送短信SMS

时间:2022-01-05 21:30:02

相关推荐

Flex使用ribbit.com的服务给手机发送短信SMS

/ 可以将语音通信和丰富的功能集成到您的网站,应用或社区。

这里说一下使用 的服务免费给手机发短信。(目前只支持美国手机号)

1. 访问 注册并下载 Flex 的类库 RibbitAPI_2.5.0.1070_FX3_CS4.swc

2. 创建Flex项目,并引入下载的RibbitAPI_2.5.0.1070_FX3_CS4.swc

3. 要免费使用的服务,需要以下信息, 大部分在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="//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);// loginrequest.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@ / subject / content

原作 /cfusion/communityengine/index.cfm?event=showdetails&postid=1&loc=en_US&productid=2

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。