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 ?
On Mon, Sep 22, 2008 at 7:40 AM, Eric (Google) <[EMAIL PROTECTED]> wrote:
>
>
>
> On Sep 17, 12:34 pm, "Mina Ramses" <[EMAIL PROTECTED]> wrote:
> > Any guide to use the java lib. in jsp pages , any type of guide ... ?
>
> I'm afraid not. You'll have to search the web for tutorials on
> creating
> JSP pages.
>
> You could try modifying the Google Health JSP sample app to work
> with Webmaster tools. That uses the the Google Data Java client:
>
> http://code.google.com/p/googlehealthsamples/source/browse/#svn/trunk/java/health_sample
>
> I would also have a look at the WT Java Developer's Guide:
> http://code.google.com/apis/webmastertools/docs/developers_guide_java.html
>
> Eric
>
> >
> >
> >
> > On Wed, Sep 17, 2008 at 10:23 PM, Eric (Google) <[EMAIL PROTECTED]>
> wrote:
> >
> > > On Sep 17, 12:15 pm, "Mina Ramses" <[EMAIL PROTECTED]> wrote:
> > > > Another question please if you don't mind .
> > > > Regarding the Java Webmastertools example, i think it's a java code,
> so
> > > i'm
> > > > asking to use it in implementing a web application can I use this
> code as
> > > > jsp pages ? or must i use another client library for web application
> >
> > > Yes. You can use the library to create .jsp pages.
> >
> > > > implementation ?
> > > > I checked the php client library but i didn't find a support for the
> > > > webmaster tools api or any samples , correct me if I'm wrong.
> >
> > > Correct, there's no support in the PHP lib.
> >
> > > > On Wed, Sep 17, 2008 at 8:18 PM, Eric (Google) <[EMAIL PROTECTED]>
> > > wrote:
> >
> > > > > Use whatever authentication method you wish,
> > > > > but here's why we discourage ClientLogin in webappss:
> >
> > > > > 1.) You need to deal with CAPTCHAs
> >
> > > > > 2.) A users credentials are exposed to your app. From a security
> > > > > perspective, it's much better for them to input this information on
> a
> > > > > Google page rather than a third party app.
> >
> > > > > 3.) ClientLogin tokens expire after ~2weeks. AuthSub/OAuth tokens
> > > > > do not expire.
> >
> > > > > Eric
> >
> > > > > On Sep 17, 9:52 am, "Mina Ramses" <[EMAIL PROTECTED]> wrote:
> > > > > > Thanks Eric for your fast reply,
> > > > > > I know about ClientLogin, but I'm asking if can i use it without
> any
> > > > > > problems to build a web application ?
> >
> > > > > > On Wed, Sep 17, 2008 at 7:46 PM, Eric (Google) <
> [EMAIL PROTECTED]>
> > > > > wrote:
> >
> > > > > > > As I mentioned, there's ClientLogin.
> >
> > > > > > > Here's the Google Data Overview on it:
> > > > > > >http://code.google.com/apis/gdata/auth.html#ClientLogin
> >
> > > > > > > and a Java Webmastertools example:
> >
> > >http://code.google.com/apis/webmastertools/docs/developers_guide_java.
> > > > > ..
> >
> > > > > > > Eric
> >
> > > > > > > On Sep 17, 9:10 am, "Mina Ramses" <[EMAIL PROTECTED]>
> wrote:
> > > > > > > > Hi Eric,
> > > > > > > > Also i want to ask , if there's no other ways to implement a
> > > > > webmaster
> > > > > > > tools
> > > > > > > > web application without using this AuthSub but in a correct
> way
> > > and
> > > > > with
> > > > > > > no
> > > > > > > > problems ? i.e bypass the AuthSub authentication by any way.
> >
> > > > > > > > On Fri, Sep 12, 2008 at 11:37 PM, Eric (Google) <
> > > [EMAIL PROTECTED]
> >
> > > > > > > wrote:
> >
> > > > > > > > > This is only an issue with Webmaster Tools. Not with the
> other
> > > > > Data
> > > > > > > > > APIs.
> >
> > > > > > > > > This is under the general Google Datas issue tracker:
> > > > > > > > >http://code.google.com/p/gdata-issues/issues/detail?id=678
> >
> > > > > > > > > To answer your last question, it's possible to write a web
> app
> > > > > > > > > that uses ClientLogin, but it's strongly discouraged.
> Sharing
> > > > > > > > > a user's credentials in a web app isn't a great idea.
> >
> > > > > > > > > Eric
> >
> > > > > > > > > On Sep 12, 12:23 pm, "Mina Ramses" <[EMAIL PROTECTED]>
> > > wrote:
> > > > > > > > > > I checkedhttp://
> > > code.google.com/p/gdata-java-client/issues/list
> > > > > > > > > > I didn't find anyone with this issue, that's why i'm
> asking
> > > how
> > > > > > > AuthSub
> > > > > > > > > > tokens are broken and this is only with webmaster tools
> api
> > > or
> > > > > all
> > > > > > > google
> > > > > > > > > > data api ?
> > > > > > > > > > I think people are working on it , which means they
> didn't
> > > use
> > > > > > > AuthSub ??
> >
> > > > > > > > > > On Fri, Sep 12, 2008 at 10:13 PM, Mina Ramses <
> > > > > [EMAIL PROTECTED]
> >
> > > > > > > > > wrote:
> > > > > > > > > > > Did you try the AuthSub ..?, didn't you report it to
> google
> > > > > support
> > > > > > > ?
> > > > > > > > > > > Can i use ClientLogin to work with a webpage ...? or no
> way
> > > ?
> >
> > > > > > > > > > > On Fri, Sep 12, 2008 at 10:08 PM, Eric (Google) <
> > > > > > > [EMAIL PROTECTED]
> > > > > > > > > >wrote:
> >
> > > > > > > > > > >> On Sep 12, 12:01 pm, cslinux <[EMAIL PROTECTED]>
> > > wrote:
> > > > > > > > > > >> > So do you mean that i can't yet use AuthSub for
> > > > > webmastertools
> > > > > > > which
> > > > > > > > > > >> > means i can't use the api for web application ?
> >
> > > > > > > > > > >> Correct. Unless you use ClientLogin for now.
> >
> > > > > > > > > > >> > On Sep 12, 9:33 pm, "Eric (Google)" <
> > > [EMAIL PROTECTED]>
> > > > > > > wrote:
> >
> > > > > > > > > > >> > > I would recommend taking a look at the Webmaster
> Tools
> > > > > > > Protocol
> > > > > > > > > Guide:
> >
> > >http://code.google.com/apis/webmastertools/docs/developers_guide.html
> >
> > > > > > > > > > >> > > And using PHP libcurl:
> > > > > > > > > > >>
> http://code.google.com/apis/gdata/articles/using_cURL.html
> >
> > > > > > > > > > >> > > And just a heads up, AuthSub tokens are currently
> > > broken
> > > > > with
> > > > > > > > > > >> > > Webmastertools:
> >
> > >http://code.google.com/p/gdata-issues/issues/detail?id=678&colspec=AP.
> > > > > > > > > ..
> >
> > > > > > > > > > >> > > Eric
> >
> > > > > > > > > > >> > > On Sep 12, 10:35 am, cslinux <
> [EMAIL PROTECTED]>
> > > > > wrote:
> >
> > > > > > > > > > >> > > > I'm asking if i can use php client library with
> > > Google
> > > > > > > webmaster
> > > > > > > > > > >> tools
> > > > > > > > > > >> > > > api, cause i only found a reference guide for
> java,
> > > > > that's
> > > > > > > why
> > > > > > > > > I'm
> > > > > > > > > > >> > > > asking, even the php client lib has no webmaster
> > > tool
> > > > > > > sample, in
> > > > > > > > > > >> case
> > > > > > > > > > >> > > > the google webmaster api isn't supported in the
> php
> > > lib,
> > > > > > > what
> > > > > > > > > could
> > > > > > > > > > >> be
> > > > > > > > > > >> > > > a good start in order to implement the api in
> php ?
> >
> > > > > > > > > > > Thanks in advance and kind regards.
> >
> > > > > > > > > > > --
> > > > > > > > > > > |Mina r. Fahmy|
> >
> > > ===============================================================
> > > > > > > > > > > Key ID: 0x964F ED94 on --keyserverhttp://
> > > wwwkeys.eu.pgp.net
> > > > > > > > > > > Key fingerprint = 35DD 3279 EB3E A711 1205 466F 4B8E
> 4940
> > > 964F
> > > > > ED94
> >
> > > ===============================================================
> >
> > > > > > > > > > Thanks in advance and kind regards.
> > > > > > > > > > --
> > > > > > > > > > |Mina r. Fahmy|
> >
> > > ===============================================================
> > > > > > > > > > Key ID: 0x964F ED94 on --keyserverhttp://
> wwwkeys.eu.pgp.net
> > > > > > > > > > Key fingerprint = 35DD 3279 EB3E A711 1205 466F 4B8E 4940
> > > 964F
> > > > > ED94
> >
> > > ===============================================================
> >
> > > > > > > > Thanks in advance and kind regards.
> >
> > > > > > > > --
> > > > > > > > |Mina r. Fahmy|
> > > > > > > >
> ===============================================================
> > > > > > > > Key ID: 0x964F ED94 on --keyserverhttp://wwwkeys.eu.pgp.net
> > > > > > > > Key fingerprint = 35DD 3279 EB3E A711 1205 466F 4B8E 4940
> 964F
> > > ED94
> > > > > > > >
> ===============================================================
> >
> > > > > > Thanks in advance and kind regards.
> >
> > > > > > --
> > > > > > |Mina r. Fahmy|
> > > > > > ===============================================================
> > > > > > Key ID: 0x964F ED94 on --keyserverhttp://wwwkeys.eu.pgp.net
> > > > > > Key fingerprint = 35DD 3279 EB3E A711 1205 466F 4B8E 4940 964F
> ED94
> > > > > > ===============================================================
> >
> > > > Thanks in advance Eric and kind regards
> >
> > > > --
> > > > |Mina r. Fahmy|
> > > > ===============================================================
> > > > Key ID: 0x964F ED94 on --keyserverhttp://wwwkeys.eu.pgp.net
> > > > Key fingerprint = 35DD 3279 EB3E A711 1205 466F 4B8E 4940 964F ED94
> > > > ===============================================================
> >
> > Thanks in advance and kind regards
> >
> > --
> > |Mina r. Fahmy|
> > ===============================================================
> > Key ID: 0x964F ED94 on --keyserverhttp://wwwkeys.eu.pgp.net
> > Key fingerprint = 35DD 3279 EB3E A711 1205 466F 4B8E 4940 964F ED94
> > ===============================================================
> >
>
Thanks in advance and kind regards.
--
|Mina r. Fahmy|
===============================================================
Key ID: 0x964F ED94 on --keyserver http://wwwkeys.eu.pgp.net
Key fingerprint = 35DD 3279 EB3E A711 1205 466F 4B8E 4940 964F ED94
===============================================================
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Data Protocol" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---