I used to write a jsp for webmasterTools as the following :
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="com.google.gdata.client.webmastertools.WebmasterToolsService,
com.google.gdata.data.OutOfLineContent,
com.google.gdata.data.webmastertools.CrawlRate,
com.google.gdata.data.webmastertools.DomainPreference,
com.google.gdata.data.webmastertools.SitesEntry,
com.google.gdata.data.webmastertools.SitesFeed,
com.google.gdata.util.AuthenticationException,
com.google.gdata.util.ServiceException,
java.text.*,
java.io.IOException,
java.net.MalformedURLException,
java.net.URL,
java.net.URLEncoder
" %>
<%!
private static final String FEED_URI_BASE
= "
http://www.google.com/webmasters/tools/feeds/";
private static final String SITES_FEED_DIRECTORY = "sites/";
private static URL getSitesFeedUrl() throws IOException {
try {
return new URL(FEED_URI_BASE + SITES_FEED_DIRECTORY);
} catch (MalformedURLException e) {
throw new IOException("URL for sites feed is malformed.");
}
}
public static void printUserSites(WebmasterToolsService myService)
throws ServiceException, IOException {
try {
System.out.println("Printing user's sites:");
// Request the feed
URL feedUrl = getSitesFeedUrl();
SitesFeed sitesResultFeed = myService.getFeed(feedUrl, SitesFeed.class);
// Print the results
for (SitesEntry entry : sitesResultFeed.getEntries()) {
System.out.println("\t" + entry.getTitle().getPlainText());
}
} catch (MalformedURLException e) {
throw new IOException("URL for sites feed is malformed.");
}
}
private static void usage() {
System.out.println("Usage: WebmasterToolsClient --username <username>"
+ " --password <password>");
System.out.println("\nA simple application that lists sites, "
+ "and Sitemaps using the provided username and "
+ "password for authentication.");
}
public static void runExamples(WebmasterToolsService myService)
throws ServiceException, IOException {
printUserSites(myService);
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
WebmasterToolsService myService = new WebmasterToolsService("exampleCo-exampleApp-1");
try {
myService.setUserCredentials("user", "password");
} catch (AuthenticationException e) {
System.out.println("The username or password entered are not valid");
System.exit(1);
}
System.out.println("Running with user ");
// Run the example methods, list sites, insert, update, etc.
try {
runExamples(myService);
} catch (ServiceException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("Sample run completed.");
%>
</body>
</html>
But i got the following errors :
"Only a type can be imported. com.google.gdata.client.webmastertools.WebmasterToolsService resolves to a package"
the WebmasterToolsService , ServiceException, SitesFeed ...etc cannot be resolved to a type at the time i used to import com.google.gdata.client.webmastertools.WebmasterToolsService, com.google.gdata.util.ServiceException, com.google.gdata.data.webmastertools.SitesFeed , ....etc
so what's wrong ?
I want to mention that i'm using eclipse and i did add all these external libs .
Any comment ?