<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>润物无声 &#187; Google</title>
	<atom:link href="http://blog.zhourunsheng.com/tag/google/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.zhourunsheng.com</link>
	<description>天空一朵雨做的云</description>
	<lastBuildDate>Sat, 08 May 2021 05:17:21 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.41</generator>
	<item>
		<title>手机安装账户同步服务</title>
		<link>http://blog.zhourunsheng.com/2014/07/%e6%89%8b%e6%9c%ba%e5%ae%89%e8%a3%85%e8%b4%a6%e6%88%b7%e5%90%8c%e6%ad%a5%e6%9c%8d%e5%8a%a1/</link>
		<comments>http://blog.zhourunsheng.com/2014/07/%e6%89%8b%e6%9c%ba%e5%ae%89%e8%a3%85%e8%b4%a6%e6%88%b7%e5%90%8c%e6%ad%a5%e6%9c%8d%e5%8a%a1/#comments</comments>
		<pubDate>Mon, 21 Jul 2014 01:14:14 +0000</pubDate>
		<dc:creator><![CDATA[润物无声]]></dc:creator>
				<category><![CDATA[程序设计]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Sony]]></category>

		<guid isPermaLink="false">http://blog.zhourunsheng.com/?p=1905</guid>
		<description><![CDATA[<p>【前提】 手机需要root过，不然没有权限拷贝apk到 /system/app 目录下面。 【步骤】 通过手机 [&#8230;]</p>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2014/07/%e6%89%8b%e6%9c%ba%e5%ae%89%e8%a3%85%e8%b4%a6%e6%88%b7%e5%90%8c%e6%ad%a5%e6%9c%8d%e5%8a%a1/">手机安装账户同步服务</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></description>
				<content:encoded><![CDATA[<h3>【前提】</h3>
<p>手机需要root过，不然没有权限拷贝apk到 /system/app 目录下面。</p>
<h3>【步骤】</h3>
<p>通过手机的【设置】--【关于手机】 查看当前系统的Android版本，例如我的手机是4.2.2。<br />
在 <a href="http://wiki.rootzwiki.com/Google_Apps">http://wiki.rootzwiki.com/Google_Apps</a> 中下载对应的服务包。<br />
<img src="http://blog.zhourunsheng.com/wp-content/uploads/2014/07/recommended_package_android.png" alt="" width="434" height="314" /></p>
<p>里面包含了很多的服务(system\app)app，我们只需要安装服务框架，登录服务，日历同步，通讯录同步，邮件同步即可。</p>
<p><img src="http://blog.zhourunsheng.com/wp-content/uploads/2014/07/install_apks.png" alt="" /><br />
拷贝到 \system\app 系统目录中。<br />
<img src="http://blog.zhourunsheng.com/wp-content/uploads/2014/07/copyapks.png" alt="" /></p>
<p><b>【账户同步】</b><br />
<img src="http://blog.zhourunsheng.com/wp-content/uploads/2014/07/google_sync.png" alt="" /></p>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2014/07/%e6%89%8b%e6%9c%ba%e5%ae%89%e8%a3%85%e8%b4%a6%e6%88%b7%e5%90%8c%e6%ad%a5%e6%9c%8d%e5%8a%a1/">手机安装账户同步服务</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zhourunsheng.com/2014/07/%e6%89%8b%e6%9c%ba%e5%ae%89%e8%a3%85%e8%b4%a6%e6%88%b7%e5%90%8c%e6%ad%a5%e6%9c%8d%e5%8a%a1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>三星 S5830i 安装谷歌同步服务</title>
		<link>http://blog.zhourunsheng.com/2012/05/%e4%b8%89%e6%98%9f-s5830i-%e5%ae%89%e8%a3%85%e8%b0%b7%e6%ad%8c%e5%90%8c%e6%ad%a5%e6%9c%8d%e5%8a%a1/</link>
		<comments>http://blog.zhourunsheng.com/2012/05/%e4%b8%89%e6%98%9f-s5830i-%e5%ae%89%e8%a3%85%e8%b0%b7%e6%ad%8c%e5%90%8c%e6%ad%a5%e6%9c%8d%e5%8a%a1/#comments</comments>
		<pubDate>Wed, 30 May 2012 05:58:52 +0000</pubDate>
		<dc:creator><![CDATA[润物无声]]></dc:creator>
				<category><![CDATA[移动开发]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[S5830i]]></category>
		<category><![CDATA[账户同步]]></category>

		<guid isPermaLink="false">http://blog.zhourunsheng.com/?p=1610</guid>
		<description><![CDATA[<p>三星 S5830i 手机的root和安装google市场可以参看系列文章《三星S5830i安装谷歌服务》，本文 [&#8230;]</p>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2012/05/%e4%b8%89%e6%98%9f-s5830i-%e5%ae%89%e8%a3%85%e8%b0%b7%e6%ad%8c%e5%90%8c%e6%ad%a5%e6%9c%8d%e5%8a%a1/">三星 S5830i 安装谷歌同步服务</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></description>
				<content:encoded><![CDATA[<p>三星 S5830i 手机的root和安装google市场可以参看系列文章《<a href="http://blog.zhourunsheng.com/tag/s5830i/">三星S5830i安装谷歌服务</a>》，本文介绍在此基础上安装谷歌的同步服务，具体包括通讯录同步，邮件同步和日历同步，安装方法如下。<span id="more-1610"></span></p>
<h2>安装顺序</h2>
<ul>
<li>下载 <a href="http://carey-blog-image.googlecode.com/files/Google_Mobile_Service%28GMS%29%E8%B0%B7%E6%AD%8C%E7%A7%BB%E5%8A%A8%E6%9C%8D%E5%8A%A1%282.3.4%29.zip">Google<em>Mobile</em>Service(GMS)谷歌移动服务(2.3.4).zip</a>，这是Android版本2.3的GMS服务包，里面包括了基本的google服务APP，不过我们不用那么多，只需要GoogleContactsSyncAdapter.apk, GoogleCalendarSyncAdapter.apk 和 Gmail.apk 就够了。</li>
<li>将解压后得到的3个APK放到系统目录<em>/system/app</em>中，然后重启手机进行自动安装</li>
<li>配置账户同步，勾选账户，日历和邮件同步的选项，稍等一会儿，所有的通讯录，日历和邮件就都同步ok了<br />
<img class="alignleft" src="http://blog.zhourunsheng.com/wp-content/uploads/2012/06/all-google-apps.png" alt="all-google-apps" width="160" height="240" /><br />
<img src="http://blog.zhourunsheng.com/wp-content/uploads/2012/06/google-sync.png" alt="google-sync" width="160" height="240" /></li>
<li>这样的话，基本所有的google服务就都具备了，以后涉及到google其他的APP都木有问题了</li>
<li>如果还想安装其他的google app，方法同上，有的只能安装到系统目录中，即/system/app下，有的可以按照普通的方法进行安装，视具体情况而定</li>
</ul>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2012/05/%e4%b8%89%e6%98%9f-s5830i-%e5%ae%89%e8%a3%85%e8%b0%b7%e6%ad%8c%e5%90%8c%e6%ad%a5%e6%9c%8d%e5%8a%a1/">三星 S5830i 安装谷歌同步服务</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zhourunsheng.com/2012/05/%e4%b8%89%e6%98%9f-s5830i-%e5%ae%89%e8%a3%85%e8%b0%b7%e6%ad%8c%e5%90%8c%e6%ad%a5%e6%9c%8d%e5%8a%a1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>三星 S5830i 安装谷歌市场 Google Market</title>
		<link>http://blog.zhourunsheng.com/2012/05/%e4%b8%89%e6%98%9f-s5830i-%e5%ae%89%e8%a3%85%e8%b0%b7%e6%ad%8c%e5%b8%82%e5%9c%ba-google-market/</link>
		<comments>http://blog.zhourunsheng.com/2012/05/%e4%b8%89%e6%98%9f-s5830i-%e5%ae%89%e8%a3%85%e8%b0%b7%e6%ad%8c%e5%b8%82%e5%9c%ba-google-market/#comments</comments>
		<pubDate>Wed, 30 May 2012 01:31:07 +0000</pubDate>
		<dc:creator><![CDATA[润物无声]]></dc:creator>
				<category><![CDATA[移动开发]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[S5830i]]></category>

		<guid isPermaLink="false">http://blog.zhourunsheng.com/?p=1605</guid>
		<description><![CDATA[<p>前几天刚把三星S5830i Root过了，现在操作起来顺畅多了，还有一个待解决的问题就是没有google服务， [&#8230;]</p>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2012/05/%e4%b8%89%e6%98%9f-s5830i-%e5%ae%89%e8%a3%85%e8%b0%b7%e6%ad%8c%e5%b8%82%e5%9c%ba-google-market/">三星 S5830i 安装谷歌市场 Google Market</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></description>
				<content:encoded><![CDATA[<p>前几天刚把三星S5830i Root过了，现在操作起来顺畅多了，还有一个待解决的问题就是没有google服务，没法安装google market，本文就介绍怎么样在手机没有内置google服务的基础上来自己安装，国内好多的定制行货手机都被裁剪掉了，真搞不懂为什么？？？好了，接下来介绍一下安装顺序，前提是你的手机已经root过了，具体怎么样root可以参照文章《<a href="http://blog.zhourunsheng.com/2012/05/%e4%b8%89%e6%98%9f-s5830i-root/">三星 S5830i root</a>》。<span id="more-1605"></span></p>
<h2>安装顺序</h2>
<ul>
<li>下载 google 服务包，里面包括 GoogleServicesFramework.apk 和 Vending.apk，注意我的三星手机目前的android版本是2.3.6，所以该谷歌服务适用于2.3，其他的版本我还没有测试过，不过装了也不会出现什么副作用，可以试试，<a href="http://carey-blog-image.googlecode.com/files/GoogleServicesFramework-Vending-2.3.zip">点我</a>下载。</li>
<li>将上面已经下载的两个APK放置到 <em>/system/app</em> 目录中，然后关机重启进行自动安装，安装以后提示google market应用升级，然后自动升级到google play store，截图如下<br />
<img class="alignleft" src="http://blog.zhourunsheng.com/wp-content/uploads/2012/06/googleservicesframework.png" alt="googleservicesframework" width="160" height="280" /><br />
<img class="alignleft" src="http://blog.zhourunsheng.com/wp-content/uploads/2012/06/vending.png" alt="vending" width="160" height="280" /><br />
<img src="http://blog.zhourunsheng.com/wp-content/uploads/2012/06/playstore.png" alt="playstore" width="160" height="280" /></li>
<li>接下来打开play store应用绑定Google账户，填写正确的google账户信息，绑定完了就ok了，截图如下：<br />
<img class="alignleft" src="http://blog.zhourunsheng.com/wp-content/uploads/2012/06/playstoresetting.png" alt="playstoresetting" width="160" height="280" /><br />
<img class="alignleft" src="http://blog.zhourunsheng.com/wp-content/uploads/2012/06/playstoresettingok.png" alt="playstoresettingok" width="160" height="280" /><br />
<img src="http://blog.zhourunsheng.com/wp-content/uploads/2012/06/playstoremainpage.png" alt="playstoremainpage" width="160" height="280" /></li>
<li>欧了，现在就可以利用play store进行apk安装和升级了，随心所欲的利用google服务</li>
</ul>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2012/05/%e4%b8%89%e6%98%9f-s5830i-%e5%ae%89%e8%a3%85%e8%b0%b7%e6%ad%8c%e5%b8%82%e5%9c%ba-google-market/">三星 S5830i 安装谷歌市场 Google Market</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zhourunsheng.com/2012/05/%e4%b8%89%e6%98%9f-s5830i-%e5%ae%89%e8%a3%85%e8%b0%b7%e6%ad%8c%e5%b8%82%e5%9c%ba-google-market/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Google Plus API 之 程序设计</title>
		<link>http://blog.zhourunsheng.com/2011/09/google-plus-api-%e4%b9%8b-%e7%a8%8b%e5%ba%8f%e8%ae%be%e8%ae%a1/</link>
		<comments>http://blog.zhourunsheng.com/2011/09/google-plus-api-%e4%b9%8b-%e7%a8%8b%e5%ba%8f%e8%ae%be%e8%ae%a1/#comments</comments>
		<pubDate>Sat, 17 Sep 2011 05:25:22 +0000</pubDate>
		<dc:creator><![CDATA[润物无声]]></dc:creator>
				<category><![CDATA[Web设计]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SAE]]></category>

		<guid isPermaLink="false">http://blog.zhourunsheng.com/?p=888</guid>
		<description><![CDATA[<p>昨天Google官方发布新闻(Getting started on the Google+ API)，Goog [&#8230;]</p>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2011/09/google-plus-api-%e4%b9%8b-%e7%a8%8b%e5%ba%8f%e8%ae%be%e8%ae%a1/">Google Plus API 之 程序设计</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></description>
				<content:encoded><![CDATA[<p>昨天Google官方发布新闻(<a href="http://googlecode.blogspot.com/2011/09/getting-started-on-google-api.html">Getting started on the Google+ <em>API</em></a>)，Google Plus开放了一个只读的API，允许抓取用户的公开Profile和公开的Activity信息流，其中<a href="http://developers.google.com/+/">Google+ Platform</a>的具体开发API介绍详见官网。</p>
<p>今天我就带领大家熟悉一下基于Google+ 开放API的程序设计，本程序基于SAE平台，采用PHP语言开发，基于Java语言和Python语言也都比较好开发，google官方都有开放的lib可以直接使用，不用自己再做底层封装了。<span id="more-888"></span></p>
<h3>实现步骤</h3>
<ol>
<li>访问 <a href="https://code.google.com/apis/console/?api=plus" rel="nofollow">Google API Console</a> 开启Google+ API权限.<br />
<img class="alignnone size-full wp-image-891" title="active_google_plus" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/09/active_google_plus.png" alt="" width="668" height="40" /></li>
<li>访问 <a href="https://code.google.com/apis/console/?api=plus" rel="nofollow">Google API Console</a> 生成  developer key, OAuth2 client id, OAuth2 client secret, 和 注册 OAuth2 redirect uri.<br />
<img class="alignnone size-full wp-image-890" title="google_plus_client_id" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/09/google_plus_client_id.png" alt="" width="754" height="151" /><br />
<img class="alignnone size-full wp-image-892" title="google-plus-simple-api-access" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/09/google-plus-simple-api-access.png" alt="" width="576" height="147" /></li>
<li>下载 google api的php开发库，<a href="http://google-api-php-client.googlecode.com/files/google-api-php-client-0.4.4.tar.gz">google-api-php-client</a>.</li>
<li>更新google api开发库，因为我的运行环境基于新浪云SAE平台，所以要做一些特别的改动：<br />
1. 实现SAE平台的MemCache，在google-api-php-clientsrccache中建立apiSAEMemcacheCache.php文件，具体内容如下</p>
<pre>&lt;?php
/**
 * SAE Memcache
 *
 * @author Carey Zhou &lt;zhourunsheng2008@google.com&gt;
 */
class apiSAEMemcacheCache extends apiCache {
  private $connection = false;

  public function __construct() {
	//do nothing
  }

  private function connect() {
    if (! $this-&gt;connection = @memcache_init()) {
      throw new apiCacheException("Memcache init failed");
    }
  }

  private function check() {
    if (! $this-&gt;connection) {
      $this-&gt;connect();
    }
  }

  /**
   * @inheritDoc
   */
  public function get($key, $expiration = false) {
    $this-&gt;check();
    if (($ret = @memcache_get($this-&gt;connection, $key)) === false) {
      return false;
    }
    if (! $expiration || (time() - $ret['time'] &gt; $expiration)) {
      $this-&gt;delete($key);
      return false;
    }
    return $ret['data'];
  }

  /**
   * @inheritDoc
   */
  public function set($key, $value) {
    $this-&gt;check();
    // we store it with the cache_time default expiration so objects will at least get cleaned eventually.
    if (@memcache_set($this-&gt;connection, $key, array('time' =&gt; time(),
        'data' =&gt; $value), false) == false) {
      throw new apiCacheException("Couldn't store data in cache");
    }
  }

  /**
   * @inheritDoc
   */
  public function delete($key) {
    $this-&gt;check();
    @memcache_delete($this-&gt;connection, $key);
  }
}</pre>
<p>2. 更新 google-api-php-clientsrccacheapiCache.php文件，将我们新添加的SAEMemcache加进去，代码如下：</p>
<pre>require_once "apiSAEMemcacheCache.php";</pre>
<p>3. 更新 google-api-php-clientsrcioapiCurlIO.php文件，修正一个bug【当Header中出现"HTTP/1.1 100 Continue"的时候，原程序会出现解析错误，导致程序崩溃，估计也是SAE环境的特殊性导致的】，具体改正如下：</p>
<p>原来的代码：</p>
<pre>// Parse out the raw response into usable bits
    list($rawResponseHeaders, $responseBody) = explode("rnrn", $data, 2);</pre>
<p>现在的代码：</p>
<pre>// Parse out the raw response into usable bits
    list($rawResponseHeaders, $responseBody) = explode("rnrn", $data, 2);
    if ($rawResponseHeaders == "HTTP/1.1 100 Continue") {
	list($rawResponseHeaders, $responseBody) = explode("rnrn", $responseBody, 2);
    }</pre>
<p>更改原因：如果出现了"HTTP/1.1 100 Continue"的时候，还要继续向下解析一次，即出现了特殊的“双Header现象”，否则的话就会导致Header解析出错，真正的Header没有被解析出来，也混到body里面去了。</li>
<li>google plus 代码编写，获取用户公开的Activity信息流，核心代码如下：
<pre>&lt;?php
/*
 * Google Plus
 *
 * @author Carey Zhou(zhourunsheng2008@gmail.com)
 */
require_once '../libs/google-api-php-client/src/apiClient.php';
require_once '../libs/google-api-php-client/src/contrib/apiPlusService.php';

//sae_set_display_errors(true);

session_start();

$client = new apiClient();
$client-&gt;setApplicationName("Google Plus Application");

$client-&gt;setClientId('800611776987-kp6h5nfv5l9gp5v2qipqhc5l8dkqe0lu.apps.googleusercontent.com');
$client-&gt;setClientSecret('5o-eK5M4iftPxB7_fhNqEAhm');
$client-&gt;setRedirectUri('https://carey.sinaapp.com/googleplus/index.php');
$client-&gt;setDeveloperKey('AIzaSyD6FERuKcWPn2xGUcgFmKW9Ush50nu6PYQ');

$client-&gt;setScopes(array('https://www.googleapis.com/auth/plus.me'));
$plus = new apiPlusService($client);

if (isset($_REQUEST['logout'])) {
  unset($_SESSION['access_token']);
}

if (isset($_GET['code'])) {
  $client-&gt;authenticate();
  $_SESSION['access_token'] = $client-&gt;getAccessToken();
  //header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
  $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
  echo "&lt;script language='javascript' type='text/javascript'&gt;";
  echo "window.location.href='$url'";
  echo "&lt;/script&gt;";
}

if (isset($_SESSION['access_token'])) {
  $client-&gt;setAccessToken($_SESSION['access_token']);
}

if ($client-&gt;getAccessToken()) {
  $me = $plus-&gt;people-&gt;get('me');

  $optParams = array('maxResults' =&gt; 100);
  $activities = $plus-&gt;activities-&gt;listActivities('me', 'public', $optParams);

  // The access token may have been updated lazily.
  $_SESSION['access_token'] = $client-&gt;getAccessToken();
} else {
  $authUrl = $client-&gt;createAuthUrl();
}
?&gt;</pre>
<p>可以注意到，在程序中我们配置了ClientID，ClientSecret，RedirectUri，DeveloperKey和Google+的scope，然后通过OAuth2机制获取用户的授权，进而来获得用户公开的Activity信息流。</li>
</ol>
<h3>程序部署和验证</h3>
<ol>
<li>把上面的代码部署到SAE平台，<a href="https://carey.sinaapp.com/googleplus/index.php">https://carey.sinaapp.com/googleplus/index.php</a><br />
<img class="alignnone size-medium wp-image-901" title="google-plus-carey-sinaapp" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/09/google-plus-carey-sinaapp-300x161.png" alt="" width="300" height="161" /></li>
<li>点击Connet Me进行OAuth2用户授权<br />
<img class="alignnone size-medium wp-image-902" title="google-plus-user-oauth" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/09/google-plus-user-oauth-300x161.png" alt="" width="300" height="161" /></li>
<li>点击Allow Access允许访问，则会回到刚才的页面，把用户的信息流抓取出来<br />
<img class="alignnone size-medium wp-image-904" title="google-plus-get-activity" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/09/google-plus-get-activity-300x161.png" alt="" width="300" height="161" /></li>
</ol>
<h3>小结</h3>
<p>到此为止，google plus 基于PHP开发的基本流程就都OK了，希望google过几天能开放出更多的API来，毕竟google+是个圈，所以圈子的API才是最核心的，O(∩_∩)O哈哈~,期待中</p>
<p>源码下载<a href="http://blog.zhourunsheng.com/wp-content/uploads/2011/09/google_plus_sae_source.zip">google_plus_sae_source</a></p>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2011/09/google-plus-api-%e4%b9%8b-%e7%a8%8b%e5%ba%8f%e8%ae%be%e8%ae%a1/">Google Plus API 之 程序设计</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zhourunsheng.com/2011/09/google-plus-api-%e4%b9%8b-%e7%a8%8b%e5%ba%8f%e8%ae%be%e8%ae%a1/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Google API</title>
		<link>http://blog.zhourunsheng.com/2011/08/google-api/</link>
		<comments>http://blog.zhourunsheng.com/2011/08/google-api/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 09:09:06 +0000</pubDate>
		<dc:creator><![CDATA[润物无声]]></dc:creator>
				<category><![CDATA[程序设计]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://blog.zhourunsheng.com/?p=636</guid>
		<description><![CDATA[<p>本文收集了一系列的Google开发API，可以有效与自己的web服务相集成，提高开发效率。 1) Lattit [&#8230;]</p>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2011/08/google-api/">Google API</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></description>
				<content:encoded><![CDATA[<p>本文收集了一系列的Google开发API，可以有效与自己的web服务相集成，提高开发效率。<br />
<img class="alignnone size-full wp-image-637" title="google-api" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/google-api.jpg" alt="" width="250" height="252" /><br />
<span id="more-636"></span></p>
<h3>1) <a href="http://code.google.com/apis/latitude/">Lattitude API</a></h3>
<p><img class="alignnone size-full wp-image-638" title="Lattitude API" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/Lattitude-API.jpg" alt="" width="500" height="375" /></p>
<h3>2) <a href="http://code.google.com/apis/earth/">Earth API</a></h3>
<p><img class="alignnone size-full wp-image-639" title="Earth API" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/Earth-API.jpg" alt="" width="500" height="356" /></p>
<h3>3) <a href="http://code.google.com/apis/earth/">Google Map API</a></h3>
<p><img class="alignnone size-full wp-image-640" title="Google Map API" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/Google-Map-API.jpg" alt="" width="500" height="310" /></p>
<h3>4)<a href="http://code.google.com/apis/maps/documentation/geocoding/"> GeoCoding API</a></h3>
<p><img class="alignnone size-full wp-image-641" title="GeoCoding API" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/GeoCoding-API.jpg" alt="" width="397" height="319" /></p>
<h3>5)<a href="http://code.google.com/apis/maps/documentation/directions/#Introduction"> Google Direction API</a></h3>
<p><img class="alignnone size-full wp-image-642" title="Google Direction API" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/Google-Direction-API.gif" alt="" width="500" height="227" /></p>
<h3>6)<a href="http://code.google.com/apis/maps/documentation/staticmaps/"> Static API</a></h3>
<p><img class="alignnone size-full wp-image-643" title="Static API" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/Static-API.png" alt="" width="500" height="493" /></p>
<h3>7)<a href="http://code.google.com/apis/maps/documentation/places/#Introduction"> Places API</a></h3>
<p><img class="alignnone size-full wp-image-644" title="Places API" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/Places-API.png" alt="" width="500" height="332" /></p>
<h3>8 ) <a href="http://code.google.com/apis/buzz/">Buzz API</a></h3>
<p><img class="alignnone size-full wp-image-646" title="Buzz API" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/Buzz-API1.png" alt="" width="500" height="449" /></p>
<h3>9)<a href="http://code.google.com/apis/friendconnect/">Friend Connect API</a></h3>
<p><img class="alignnone size-full wp-image-661" title="Friend Connect API" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/Friend-Connect-API.png" alt="" width="432" height="426" /></p>
<h3>10)<a href="http://code.google.com/apis/socialgraph/"> Social Graph API</a></h3>
<p><a href="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/Social-Graph-API.jpg"><img class="alignnone size-full wp-image-660" title="Social Graph API" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/Social-Graph-API.jpg" alt="" width="500" height="496" /></a></p>
<h3>11) <a href="http://code.google.com/apis/wave/">Wave API</a></h3>
<p><img class="alignnone size-full wp-image-659" title="Wave API" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/Wave-API.jpg" alt="" width="500" height="325" /></p>
<h3>12)<a href="http://code.google.com/apis/youtube/overview.html"> YouTube API’s</a></h3>
<p><img class="alignnone size-full wp-image-663" title="YouTube API" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/YouTube-API.jpg" alt="" width="500" height="375" /></p>
<h3>13)<a href="http://code.google.com/apis/adwords/"> ADwords API</a></h3>
<p><img class="alignnone size-full wp-image-657" title="ADwords API" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/ADwords-API.png" alt="" width="500" height="237" /></p>
<h3>14) <a href="http://code.google.com/apis/adsense/">Adsense API</a></h3>
<p><img class="alignnone size-full wp-image-656" title="Adsense API" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/Adsense-API1.jpg" alt="" width="558" height="70" /></p>
<h3>15)<a href="http://code.google.com/apis/blogger/"> Blogger Data API</a></h3>
<p><img class="alignnone size-full wp-image-654" title="Blogger Data API" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/Blogger-Data-API.png" alt="" width="500" height="237" /></p>
<h3>16)<a href="http://code.google.com/apis/webmastertools/"> Webmaster Tools API</a></h3>
<p><img class="alignnone size-full wp-image-653" title="Webmaster Tools API" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/Webmaster-Tools-API.png" alt="" width="500" height="237" /></p>
<h3>17) <a href="http://code.google.com/apis/codesearch/">Code Search API</a></h3>
<p><img class="alignnone size-full wp-image-652" title="Code Search API" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/Code-Search-API.png" alt="" width="500" height="237" /></p>
<h3>18) <a href="http://code.google.com/apis/picasaweb/overview.html">Picasa Web Album  DATA API</a></h3>
<p><img class="alignnone size-full wp-image-651" title="Picasa Web Album  DATA API" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/Picasa-Web-Album-DATA-API.png" alt="" width="500" height="237" /></p>
<h3>19) <a href="http://code.google.com/apis/analytics/docs/mgmt/home.html">Management API</a></h3>
<p><img class="alignnone size-full wp-image-650" title="Management API" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/Management-API.png" alt="" width="500" height="237" /></p>
<h3>20) <a href="http://code.google.com/apis/webfonts/">Font API</a></h3>
<p><img class="alignnone size-full wp-image-649" title="Font API" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/Font-API.png" alt="" width="500" height="237" /></p>
<h3>21)<a href="http://code.google.com/apis/urlshortener/"> URL Shortner API</a></h3>
<p><img class="alignnone size-full wp-image-648" title="URL Shortner API" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/08/URL-Shortner-API.png" alt="" width="500" height="237" /></p>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2011/08/google-api/">Google API</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zhourunsheng.com/2011/08/google-api/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google ClientLogin for Installed Applications</title>
		<link>http://blog.zhourunsheng.com/2011/07/google-clientlogin-for-installed-applications/</link>
		<comments>http://blog.zhourunsheng.com/2011/07/google-clientlogin-for-installed-applications/#comments</comments>
		<pubDate>Sat, 02 Jul 2011 06:20:22 +0000</pubDate>
		<dc:creator><![CDATA[润物无声]]></dc:creator>
				<category><![CDATA[程序设计]]></category>
		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://blog.zhourunsheng.com/?p=205</guid>
		<description><![CDATA[<p>访问Google的很多服务都需要账户的验证，例如Google Calendar，Google Mail，Goo [&#8230;]</p>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2011/07/google-clientlogin-for-installed-applications/">Google ClientLogin for Installed Applications</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></description>
				<content:encoded><![CDATA[<p>访问Google的很多服务都需要账户的验证，例如Google Calendar，Google Mail，Google Apps等等，其中ClientLogin验证是使用最多的情况。</p>
<p>本文就简单介绍一下手机应用程序和桌面应用程序的ClientLogin的基本流程和方法。</p>
<p><strong>The ClientLogin authorization process（验证过程）</strong></p>
<p>Authorization with ClientLogin involves a sequence of interactions between three entities: the installed application, Google services, and the user.</p>
<p>This diagram illustrates the sequence:</p>
<p> <a href="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/ClientLogin-authorization-process.jpg"><img class="alignnone size-full wp-image-206" title="ClientLogin-authorization-process" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/ClientLogin-authorization-process.jpg" alt="" width="500" height="226" /></a></p>
<p>图片中的验证流程说明如下：</p>
<p>1. When the third-party application needs to access a user's Google service, it retrieves the user's login name and password.</p>
<p>2. The third-party application then makes a ClientLogin call to Google's Authorization service.</p>
<p>3. If the Google Authorization service decides additional vetting is necessary, it returns failure response with a CAPTCHA token and challenge, in the form of a URL for a CAPTCHA image.</p>
<p>4. If a CAPTCHA challenge is received, the third-party application displays the CAPTCHA image for the user and solicits an answer from the user.</p>
<p>5. If requested, the user submits an answer to the CAPTCHA challenge.</p>
<p>6. The third-party application makes a new ClientLogin call, this time including the CAPTCHA answer and token (received with the failure response).</p>
<p>7. On a successful login attempt (with or without CAPTCHA challenge), the Google Authorization service returns a token to the application.</p>
<p>8. The application contacts the Google service with a request for data access, referencing the token received from the Google Authorization service.</p>
<p>9. If the Google service recognizes the token, it supplies the requested data access.</p>
<p><strong>The ClientLogin interface（ClientLogin验证接口）</strong></p>
<p> 1. ClientLogin</p>
<p>ClientLogin can be used with any application that can make an HTTPS POST request. The POST request should be structured as a form post with the default encoding application/x-www-form-urlencoded. Parameters should be included in the body of the post.</p>
<p>Action URL parameter: <a href="https://www.google.com/accounts/ClientLogin">https://www.google.com/accounts/ClientLogin</a></p>
<p><a href="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/ClientLogin.jpg"><img class="alignnone size-full wp-image-207" title="ClientLogin" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/ClientLogin.jpg" alt="" width="500" height="223" /></a></p>
<p>Sample request（请求示例）</p>
<p>The first example illustrates a basic login request.</p>
<p>The second example shows a request containing a response to a CAPTCHA challenge. Both examples are shown not URL-encoded for clarity.</p>
<pre>POST /accounts/ClientLogin HTTP/1.0

Content-type: application/x-www-form-urlencoded
accountType=HOSTED_OR_GOOGLE&amp;Email=zhourunsheng2008@gmail.com&amp;Passwd=12345678&amp;service=ah&amp;source=Carey-CareyDiary-1.0

~~~~~~~~~~~~~~

POST /accounts/ClientLogin HTTP/1.0

Content-type: application/x-www-form-urlencoded
accountType=HOSTED_OR_GOOGLE&amp;Email=zhourunsheng2008@gmail.com&amp;Passwd=12345678&amp;service=ah&amp;

source=Carey-CareyDiary-1.0&amp;logintoken=DQAAAGgA...dkI1LK9&amp;logincaptcha=abcdefg</pre>
<p>2. ClientLogin response</p>
<p>In response to a login request, Google returns either an HTTP 200, if login succeeded, or an HTTP 403, if login failed.</p>
<p>A success response contains the authorization token, labeled "Auth", in the body of the response. Your application must reference this token in each request to the Google service for this user. Additional cookies, labeled "SID" and "LSID", are not currently active and should not be used.</p>
<p>A failure response contains an error code and a URL to an error page that can be displayed to the user. If the error code is a CAPTCHA challenge, the response also includes a URL to a CAPTCHA image and a special token. Your application should be able to solicit an answer from the user and then retry the login request. To display the CAPTCHA image to the user, prefix the CaptchaUrl value with "http://www.google.com/accounts/", for example: " http://www.google.com/accounts/Captcha?ctoken=HiteT4b0Bk5Xg18_AcVoP6-yFkHPibe7O9EqxeiI7lUSN".</p>
<p>Sample responses（回复示例）</p>
<pre>HTTP/1.0 200 OK

Server: GFE/1.3

Content-Type: text/plain

SID=DQAAAGgA...7Zg8CTN

LSID=DQAAAGsA...lk8BBbG

Auth=DQAAAGgA...dk3fA5N

在我们的程序中，目前主要利用Auth来作为后续访问服务的token，其他两项没有作用

~~~~~~~~~

HTTP/1.0 403 Access Forbidden

Server: GFE/1.3

Content-Type: text/plain

Url=http://www.google.com/login/captcha

Error=CaptchaRequired

CaptchaToken=DQAAAGgA...dkI1LK9

CaptchaUrl=Captcha?ctoken=HiteT4b0Bk5Xg18_AcVoP6-yFkHPibe7O9EqxeiI7lUSN</pre>
<p><strong>Error codes（错误代码）</strong></p>
<p> <a href="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/Error-codes.jpg"><img class="alignnone size-full wp-image-208" title="Error-codes" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/Error-codes.jpg" alt="" width="500" height="171" /></a></p>
<p>详细文档： <a href="http://code.google.com/intl/zh-CN/apis/accounts/docs/AuthForInstalledApps.html" target="_blank">Google AuthForInstalledApps</a></p>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2011/07/google-clientlogin-for-installed-applications/">Google ClientLogin for Installed Applications</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zhourunsheng.com/2011/07/google-clientlogin-for-installed-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>脚本方式获取Google ClientLogin Auth Token</title>
		<link>http://blog.zhourunsheng.com/2011/07/%e8%84%9a%e6%9c%ac%e6%96%b9%e5%bc%8f%e8%8e%b7%e5%8f%96google-clientlogin-auth-token/</link>
		<comments>http://blog.zhourunsheng.com/2011/07/%e8%84%9a%e6%9c%ac%e6%96%b9%e5%bc%8f%e8%8e%b7%e5%8f%96google-clientlogin-auth-token/#comments</comments>
		<pubDate>Sat, 02 Jul 2011 06:06:53 +0000</pubDate>
		<dc:creator><![CDATA[润物无声]]></dc:creator>
				<category><![CDATA[程序设计]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://blog.zhourunsheng.com/?p=190</guid>
		<description><![CDATA[<p>在开发基于Google服务的应用程序中，有很多的情况都需要获取Auth Token。 本文编写了一个简单的sh [&#8230;]</p>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2011/07/%e8%84%9a%e6%9c%ac%e6%96%b9%e5%bc%8f%e8%8e%b7%e5%8f%96google-clientlogin-auth-token/">脚本方式获取Google ClientLogin Auth Token</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></description>
				<content:encoded><![CDATA[<p>在开发基于Google服务的应用程序中，有很多的情况都需要获取Auth Token。</p>
<p>本文编写了一个简单的shell脚本文件，可方便程序开发人员快速的获取到Auth Token来调试程序。</p>
<p> 本示例程序获取的Googel服务为ah，即Google App Engine，如果需要获取其他服务的token，只要修改脚本中的 service=ah 为自己的服务即可。</p>
<p><strong>Google 常用服务和Service Name 对照表</strong></p>
<table width="400">
<tbody>
<tr>
<th>Google API</th>
<th>Service name</th>
</tr>
<tr>
<td>Google Analytics Data APIs</td>
<td><code>analytics</code></td>
</tr>
<tr>
<td>Google Apps APIs<br />
<em>(Domain Information &amp; Management)</em></td>
<td><code>apps</code></td>
</tr>
<tr>
<td>Google Base Data API</td>
<td><code>gbase</code></td>
</tr>
<tr>
<td>Google Sites Data API</td>
<td><code>jotspot</code></td>
</tr>
<tr>
<td>Blogger Data API</td>
<td><code>blogger</code></td>
</tr>
<tr>
<td>Book Search Data API</td>
<td><code>print</code></td>
</tr>
<tr>
<td>Calendar Data API</td>
<td><code>cl</code></td>
</tr>
<tr>
<td>Google Code Search Data API</td>
<td><code>codesearch</code></td>
</tr>
<tr>
<td>Contacts Data API</td>
<td><code>cp</code></td>
</tr>
<tr>
<td>Documents List Data API</td>
<td><code>writely</code></td>
</tr>
<tr>
<td>Finance Data API</td>
<td><code>finance</code></td>
</tr>
<tr>
<td>Gmail Atom feed</td>
<td><code>mail</code></td>
</tr>
<tr>
<td>Health Data API</td>
<td><code>health</code><br />
<code>weaver</code> (H9 sandbox)</td>
</tr>
<tr>
<td>Maps Data APIs</td>
<td><code>local</code></td>
</tr>
<tr>
<td>Picasa Web Albums Data API</td>
<td><code>lh2</code></td>
</tr>
<tr>
<td>Sidewiki Data API</td>
<td><code>annotateweb</code></td>
</tr>
<tr>
<td>Spreadsheets Data API</td>
<td><code>wise</code></td>
</tr>
<tr>
<td>Webmaster Tools API</td>
<td><code>sitemaps</code></td>
</tr>
<tr>
<td>YouTube Data API</td>
<td><code>youtube</code></td>
</tr>
</tbody>
</table>
<p> Google Service 评测请参照<a href="http://ruscoe.net/google/google-account-service-names/" target="_blank"> Google Account Service Names</a>（Google工程师<strong>Tony Ruscoe</strong>）</p>
<p>脚本代码如下（get_auth_token.sh）：</p>
<pre>#!/bin/sh

# Get user email
read -p "Email: " EMAIL

# Get user password
stty -echo
read -p "Password: " PASSWORD; echo &gt;&amp;2
stty echo

# check and download cacert file
CACERTFILE="/tmp/cacert.pem"
if [ ! -f "$CACERTFILE" ]; then
  wget http://curl.haxx.se/ca/cacert.pem -O $CACERTFILE
else
  echo "cacert exist!!!"
fi

# Get a user auth token
echo Getting token from https://www.google.com/accounts/ClientLogin ... &gt;&amp;2
AUTH=$(CURL_CA_BUNDLE=$CACERTFILE 
	curl -S --location 

https://www.google.com/accounts/ClientLogin

	-d Email=$EMAIL 
	-d Passwd=$PASSWORD 
	-d accountType=HOSTED_OR_GOOGLE 
	-d source=carey 
	-d service=ah 
	--header 'Content-Type:application/x-www-form-urlencoded' 
	2&gt;/dev/null 
	| awk -F= '$1 ~ /Auth/ {print $2}')

if [ -z "${AUTH}" ]; then
  echo "Auth error" &gt;&amp;2
  exit
else
  echo "Auth="$AUTH
fi</pre>
<p> </p>
<p>程序使用如下：</p>
<p>$ ./get_auth_token.sh</p>
<p>Email:            输入自己的Google帐号</p>
<p>Password:    输入自己的Google密码</p>
<p>Auth=DQAAALIAAABNfSYKsytsIx_vzFOG_iHVO4Zv8su6hyn-5cTCtObnLTd1X8K0TDoNC5zdRZTg2NQtn6S47Jw1t3ZfE2J</p>
<p>qDhR_x4KezoWYufUloCVA_pkC3g1vAcy6KIGcqiSH2hecJa5UH9yuURyF7_ODS6ysjYZ0JC9WnuF3vsx_9mO4xFGOGtyw</p>
<p>xMYfGC-j801I1Pna0AJ48T-lCeU1yEiTyUUsLPVszWrvg5ae4BPOtTaZxD_lU4lJhYAXtvLNN1ZGdLJ_huI</p>
<p>最后可以利用获取到的Auth Token来访问google的服务了。</p>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2011/07/%e8%84%9a%e6%9c%ac%e6%96%b9%e5%bc%8f%e8%8e%b7%e5%8f%96google-clientlogin-auth-token/">脚本方式获取Google ClientLogin Auth Token</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zhourunsheng.com/2011/07/%e8%84%9a%e6%9c%ac%e6%96%b9%e5%bc%8f%e8%8e%b7%e5%8f%96google-clientlogin-auth-token/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
