My first steps with RIBBIT API

Today I spent an hour to take a look at Ribbit api and to start a first flex example with them.
For now you make a call to USA phone numbers only, in fact when you enter your Ribbit profile, you receive a USA number to use for test.
So I use Skype to make a call to my Ribbit number.
Example is very easy but with this few code you can receive and  make call to USA number (Europe number  are available  in mid 2008 probably).

After registrarion and approval from Ribbit team you can download SWC from Ribbit site that you add in your Flex application.

First of all you must create a Ribbit istance and a CallObject:

 private var myRibbit:RibbitRequest = new RibbitRequest();  private var ribbitObj:CallObject; 

Then you add listner to know when you are logged in Ribbit server, when you are making a call and when you are receiving a call.

 myRibbit.addEventListener(RibbitResponseEvent.LOGGED_IN, handleLoggedIn);
 myRibbit.addEventListener(RibbitResponseEvent.RIBBIT_SERVER_CONNECTED, handleRibbitServerConnected);
 myRibbit.addEventListener(RibbitResponseEvent.CALL_CONNECTED, handleCallActive);
 myRibbit.addEventListener(RibbitResponseEvent.INCOMING_CALL, handleCallIncoming);

So you login with:

myRibbit.login("user", "psw", "devID", "appID");

All data that you put in login method you can find in your Ribbit profile.

Then you create  function  that you define in Ribbit object listner:

private function handleCallIncoming(e:RibbitResponseEvent):void{                       receiveBtn.enabled = true;                       ribbitObj = new CallObject();      ribbitObj = e.data as CallObject;                  }              private function handleCallActive(e:RibbitResponseEvent):void{                 trace("call active man!")              }              private function handleLoggedIn(e:RibbitResponseEvent):void{                   trace("you are logged in")              }              private function handleRibbitServerConnected(e:RibbitResponseEvent):void{ 
    trace("server ok")                      makeBtn.enabled = true;              }

So now we only put in our flex project 2 buttons, one to receive a call and another one to make a call to a specific USA number.

<mx:VBox>
    <mx:Button id="makeBtn" label="make call" click="{myRibbit.makeCall('USAPhone')}" enabled="false" />
    <mx:Button id="receiveBtn" label="receive call" click="{myRibbit.answerCall(ribbitObj)}" enabled="false" />
</mx:VBox>  

Very easy to use and so powerfull API!

I remember to all that Ribbit team launch a phone contest, more information in Ribbit site

Enjoy!

Published by

lucamezzalira

I’m the VP of Architecture at DAZN with more than 15 years of experience, a Google Developer Expert on Web Technologies and the London Javascript community Manager I had the chance to work on cutting-edge projects for mobile, desktop, web, TVs, set top boxes and embedded devices. I am currently managing DAZN, a sports video platform based on the cloud with millions of users that are watching live and on-demand contents. I'm the author of Front-End Reactive Architectures published by APress: https://goo.gl/ywAmsx I think the best way to use any programming language is mastering their models, that’s why I spent a lot of time studying and researching on topics like OOP, Functional and Reactive programming. In my spare time, I wrote for national and international technical magazines and editors, I'm also a technical reviewer for APress, Packt Publishing, Pragmatic Bookshelf and O'Reilly. I was speaker at: O'Reilly media webinars, O'Reilly Software Architecture (San Francisco & London), O'Reilly Fluent (San Jose), O'Reilly Oscon (London), Google Developers Summit (Krakow), Google DevFest (London), Frontend Devs Love (Amsterdam), Voxxed Days (Belgrad & Bristol), JeffConf (Milan), International Javascript Conference (Munich & London), JS Poland (Warsaw), Code Europe (Wroclaw), JSDay (Verona), CybercomDev (Łódź), Jazoon Conference (Bern), JDays (Göteborg), Codemotion (Milan), FullStack Conference (London), React London UG (London), Scrum Gathering (Prague), Agile Cymru (Cardiff), Scotch on the rocks (Edinburgh & London), 360Max (San Francisco), PyCon (Florence), Lean Kanban Conference (London), Adobe Creative Suite CS 5.5 - Launch event (Milan), Mobile World Congress (Barcelona)

3 thoughts on “My first steps with RIBBIT API”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s