API for JAVA
Hello!, today I am going to be presenting a new small project called foursquared-desktop-api about an API that lets you interact with FourSquare.com . This project that takes advantage the work made by the authors of foursquared , an excelent opensouce mobile app, originally made for android. I decided to release a Java version since I could not find anything like this arond.
Some of the best features are…
- Complete class model of foursquare objects and messages.
- Json parsers for all the messages.
- Version #1 of the api is supported.
- It identifies as a mobile app (by default)
- Nice and clean coding.
- Able to use both Http and Oauth.
Project Summary:
- URL: http://code.google.com/p/foursquared-desktop-api/
- JAR File : http://code.google.com/p/foursquared-desktop-api/downloads/detail?name=foursquared-desktop-api.jar&can=2&q=#makechanges
That’s all folks by now! Next time I probably will be introducing some of the work I am doing with this API.
Thanks for reading and feel free to send me any comments. Below I pasted a short Junit (sample code) with basic usage of this api.
Sample Usage :
-
package com.lemil.forsquares.server.foursquare.api;
-
import junit.framework.TestCase;
-
import org.json.JSONObject;
-
import com.lemil.forsquares.api.foursquare.FoursquareApi.Location;
-
import com.lemil.forsquares.api.foursquare.types.Checkin;
-
import com.lemil.forsquares.api.foursquare.types.CheckinResult;
-
import com.lemil.forsquares.api.foursquare.types.Group;
-
import com.lemil.forsquares.server.ForSquaresServiceImpl;
-
public class ForSquaresServiceTest extends TestCase {
-
ForSquaresServiceImpl service = null;
-
public ForSquaresServiceTest() {
-
}
-
super.setUp();
-
service = new ForSquaresServiceImpl(phoneNumber, password);
-
service.loadApi();
-
}
-
public void testLogin(){
-
try {
-
boolean b = service.isApiLoaded();
-
assert(b);
-
e.printStackTrace();
-
assert(false);
-
}
-
}
-
//Group<Checkin> getRecentCheckinsFromFriends() throws IllegalArgumentException ;
-
public void testGetRecentCheckinsFromFriends(){
-
try {
-
Location location = new Location(geolat, geolong);
-
for(Checkin c : fc) {
-
JSONObject o = new JSONObject(c);
-
}
-
assert(true);
-
e.printStackTrace();
-
assert(false);
-
}
-
}
-
//CheckinResult checkin(String input) throws IllegalArgumentException;
-
public void testCheckin(){
-
try {
-
Location location = new Location(“-34.54567867050709″, “-58.48865747451782″);
-
boolean isPrivate = true;
-
boolean tellFollowers = false;
-
boolean twitter = false;
-
boolean facebook = false;
-
CheckinResult c = service.checkin(venueId, venueName, location, shout, isPrivate, tellFollowers, twitter, facebook);
-
JSONObject o = new JSONObject(c);
-
assert(true);
-
e.printStackTrace();
-
assert(false);
-
}
-
}
Leave a Reply