dra*_*pon 6 java google-webmaster-tools
我一直在抨击这几天,试图弄清楚这是怎么做的.我想从Google网站站长工具中下载CSV,这是我成功完成的.但是,我必须直接传递我希望访问的帐户的用户名和密码.对于网站管理员工具的所有其他方面,我只需要用户登录,然后使用可重复使用的会话令牌从登录中交换令牌.
在获取查询数据时,似乎无法使用此方法.
String next = "http://xyz.domain.com/auth"; //sets page to goto after user log's in so we can pass the token to application
String scope = "http://www.google.com/webmasters/tools/feeds"; // sets the scope of the token
boolean secure = false;
boolean session = true;
String urlFromAuthSub = AuthSubUtil.getRequestUrl(next, scope, secure, session); //generates the URL to forward user to loginto google.
Run Code Online (Sandbox Code Playgroud)
在捕获页面(上面代码中的下一个参数)上,您在成功登录后收到令牌.然后将它换成会话令牌.
String token = "##########################";
String sessionToken = AuthSubUtil.exchangeForSessionToken(token, null);
//store sessionToken for all future use to interact with webmaster for this user.
Run Code Online (Sandbox Code Playgroud)
最后我们简单地创建我们的WebmasterToolsService对象并将其设置AuthSubToken为会话令牌,然后完成!
WebmasterToolsService myService = new WebmasterToolsService("DemoWebmaster");
myService.setAuthSubToken(token);
Run Code Online (Sandbox Code Playgroud)
但是,在尝试下载CSV时,我别无选择,只能使用Google用户的完整凭据.
String host = "www.google.com";
String dl_list_url = "/webmasters/tools/downloads-list?hl=%s&siteUrl=%s";
String sites_path = "/webmasters/tools/feeds/sites/";
WebmasterToolsService svc = new WebmasterToolsService("DemoQuery Service");
svc.setUserCredentials("xyz@domain.com", "123456");
Run Code Online (Sandbox Code Playgroud)
之后我可以使用网站管理员API做任何事情,因为我正在通过完整的客户端登录.但是,对于我正在构建的应用程序,我不需要存储用户完整的Google凭据.
我看到有一家公司在您添加Google网站管理员API时设法解除了这个问题.但我似乎无法看到它是如何可能的.有任何想法吗?
关于正在做这件事的公司,他们是谁,他们是否提供某种公共工具或混搭?也许他们只是使用一些不公平的伎俩来保留您的数据。你有网址吗?
据我所知(而且我确实知道进一步的研究以防万一)这是不可能的。有几件事:
所以,我担心你不会那么幸运。