Ribbit可以将语音通信和丰富的功能集成到您的网站,应用或社区。这里说一下使用ribbit.com 的服务免费给手机发短信。
Ribbit Corporation硅谷一家电话公司,成立于2006年2月。Ribbit是一个基于云计算的网络电话服务,具有网络通话、智能呼叫路由和语音邮件转 录功能。Ribbit和Google Voice一样,也向用户提供一个免费的电话号码(美国虚拟号码),可以免费拨打美国和加拿大,也可以免费接听来电。[详细]
下面说一下使用 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了,通常是用户名和项目名的组合。
- <?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 e.g. lxvoip";
- private static const password : String = "Your Password";
- private static const devHandle : String = "Your Developer ID e.g. lxvoip";
- 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>
相关标签:ribbit(3) 凌霄电话家园