Custom Search

Java API Usage

Usage

Google Voice Java is set of API. You must first have a Google Voice Account and know how to hack some Java for this to be useful.

So far our tests of this library have worked well. To do a simple command line test, enter the following in your commandline:


This will log in, display your Auth key, fetch contents of your inbox and sentbox, and display the HTML. It runs the test.jar script. Add the jar to your classpath and access the Voice.class to do whatever you need.


...
import com.techventus.server.voice.Voice;
...

Voice voice = new Voice(userName, pass);
...


voice.getInbox();

This function, and the other similar functions return raw HTML or XML code which must be parsed by you. A parse function can be created

To place a call, you simply pass the number from which you wish to call (originNumber) and the number being called (destinationNumber). Google Voice only allows you to use an Origin Number which has already been registered with them as associated with that Google Voice Account.


example:
...
String originNumber = "2125551234";
String destinationNumber = "4155557895";
voice.call(originNumber, destinationNumber);
...

When this code is run, the originNumber will ring first (assuming the registration checks out).
...
voice.sendSMS(destinationNumber, txt);
...


When creating the Voice object, your login details are stored in memory and the Google Client Login token or "auth" key is obtained. This token is passed back on all subsequent calls. If your program is running for a while the token may be timeout
In this case you can Relogin by renewing the auth token

...
voice. login();
...

This function is invoked automatically when you first create the Voice object.

ReCaptha Issue: If something is off and you trigger a CAPTCHA from Google Voice, you will probably have to log back into the account manually. This API is not equipped to handle the CAPTCHA request in any meaningful way at this time.
Enable/Disable Phones to Receive Calls


protected String id;
protected String number;
protected String formattedNumber;
protected String type;
protected String name;
protected String carrier;
protected Boolean verified;

perhaps the easist way to determine the id of the phone you wish to enable or disable is to search the name variable of Phones in the list and then call the id variable.

Once the id is determined, enable or disable with:

voice. phoneEnable(int ID);
voice. phoneDisable(int ID);

A String is returned with Google's result output of this action.
Other Callable Functions

A complete list of available functions to check to pull recent info from the Google Voice Account. Again, it is up to you to do the parsing. All functions return a String or throw an IOException.

getGeneral()
getInbox()
getStarred()
getRecent()
getSpam()
getRecorded()
getPlaced()
getReceived()
getMissed()
getSMS()
Since this is still in development stage visit Main Development site for the latest updates or contact the project owner ,


Googlevoice.org is a news & article portal powered by Moonrank USA. **Googlevoice.org is not sponsored by or affiliated with Google.