|
Project Information
Featured
Downloads
Links
|
WelcomeThis is a simple Java library to connect to the AdMob statistics server. With this you can include stats on your specific ads, ad groups, campaigns or sites straight into your Java applications. This was written to support a Windows Desktop Gadget and as such error checking was not very important for us to complete however I have created an exceptions class that you can expand on for your needs. If you would like to further this project or provide constructive input for changes please feel free to contact me. RequirementsAdMob Account
ExampleHere is an example of how you might use this API. The code shown here logs into your AdMob account, grabs a list of your "house ads" (as a JSON string), then outputs the IDs for those ads, and finally logs back out of your account. For a complete list of all supported calls visit the AdMob api documentation. http://developer.admob.com/wiki/API import org.json.JSONArray;
import org.json.JSONObject;
import com.ToxicBakery.AdMobApi.AdMobStats;
public class example {
private static final String CLIENT_KEY = "";
private static final String USERNAME = "";
private static final String PASSWORD = "";
/**
* @param args
*/
public static void main(String[] args) throws Exception {
//load the api
AdMobStats api = new AdMobStats(CLIENT_KEY, USERNAME, PASSWORD);
//attempt to login
api.login();
//create a request to pull all ads you have setup in admob
JSONArray allAds = api.getData("ad", "search", new String[0]);
//go through the returned array
for(int i=0;i<allAds.length();i++){
//pull the entire line of data
System.out.println(allAds.get(i));
//convert the line of data to a json object so we can pick specific data out of it
JSONObject adObject = new JSONObject(allAds.get(i).toString());
//pull the id from the data
System.out.println(adObject.getString("id"));
}
//attempt to logout
api.logout();
//close up
System.exit(0);
}
}
AdditionalThe original source code written for this library was generated to be used in conjunction with a (currently underdevelopment) Toxic Bakery product. If you are interested in a real world use of this code please check out our blog for an update. |