Friday, January 29, 2010

Google Voice on App Engine

Google voice still doesn't release their official API, but some people already did some job so that we can use Google Voice more conveniently.


Chad Smith made the Google Voice Firefox addon, which is a great tool that you can use it with your Google Voice number and send SMS message without laving your browser. Chad also posted a topic to introduce how to place calls or send SMS using Google Voice via HTTP or XML request.

See: http://posttopic.com/topic/google-voice-add-on-development

According to Chad’s article, before Google release the API, to use Google Voice’s features in a standalone program is also possible. pygooglevoice is one of this kinds of open-source projects: http://code.google.com/p/pygooglevoice/ 

Scott Hillman also wrote a script with similar functions to use in command line.

http://everydayscripting.blogspot.com/2009/10/python-custom-google-voice-api.html


I tried to use their library/script in my Google App Engine based web application, and then I met a mess of problems.


Firstly, App Engine supply the URL fetch service API to work with HTTP request. Although you can also make HTTP request using urllib, urllib2 or httplib, but actually, all these kinds of routine call will be redirect to urlfetch API. But URL fetch service has a lot of limitation; it doesn’t handle the Cookies, so that you can't login to Google account in the background before send HTTP request to Google Voice.


Scott did a helper class to handle the Cookies and resolved the login issue.

http://everydayscripting.blogspot.com/2009/08/google-app-engine-cookie-handling-with.html


When I used his URLOpener class to login Google account in my program, I met the exception of "Stripped prohibited headers from URLFetch request: ['Host']". As Google does some restriction in the latest version of App Engine, some HTTP request headers will be recognized as distrustful. So I recommend you to delete the ‘Host’ parameter from headers in Scott’s class. The URLOpener still work normally after comment the “Host” parameter.


Then, I started to replace the HTTP request API in pygooglevoice with Scott’s URLOpener class, and some other problems arose.

pygooglevoice use ConfigParser to store the configuration properties, ConfigParse is not supported by App Engine, so you need to refactor this class. I changed the Conf class to inherit from appengine’s db.Model.

You may meet the encode problem when using pygooglevoice to send SMS message. I fixed the issue by unicode the input text and then encode it to utf-8 standard.

Everything is OK now, you can test the SMS sending feature on my home page: http://cpedia.net/ 



I will continue to work on a new open-source project, integrate pygooglevoice with all the fixes above together, and demonstrate a sample application on appspot.

http://code.google.com/p/googlevoice-gae/

Tags: voice, appengine, python, featured


Wednesday, November 11, 2009

Reverse proxy for my Google App Engine application.

Thanks to G.F.W, my site couldn't be accessed in China mainland for a long time. Before that, I had my DNS CNAME point to one of the available ghs.google.com ip addresses. But unfortunately, all the available ghs IPs are blocked by G.F.W until now.

I can not give up using GAE to build my site and some other applications. "Easy to scale" is the greatest advantage that we can not give away. This advantage can not be matched by some other site/app building solution, such as virtual host.

A reverse proxy is always used for load balancing or caching, but being used as springboard between china clients and google server is only a last resort.

So I bought a VPS server to set up my proxy server using Nginx.

The VPS server bought from burst.net, I chose the $5.95/MONTH linux vps package and paid annually for only $59.50. As the things go, It's well worth the money.
(Tips: Don't pay by credit card with non-US billing address, that's unacceptable. I tried and failed and finally paid by paypal eCheck.)

VPS Software: vePortal™ / OpenVZ™
CPU: 1000MHZ GUARANTEED
Memory: 512MB GUARANTEED
Disk Space: 20GB (RAID BASED CONFIG)
Bandwidth: 1000GB/MONTH
IP Addresses: 2
Management: BASIC MANAGED
DDOS Protection: CISCO™ GUARD
FREE SETUP $5.95/MONTH


And I am also working on a OpenVPN setup under the VPS. Then not only my site/app can "climb over the wall", but also I can access some famous web applications such as twitter and YouTube in China.

Tags: appengine, vps


Wednesday, August 26, 2009

Delicious access from Google app engine issue fixed

不知道什么时候起从GAE里访问del.ico.us的feeds突然出错了,用GAE urlfetch API访问delicious的feed url总是被yahoo的服务器返回999错误代码。无奈下,我先到Google App Engine Group发贴过去问
http://groups.google.com/group/google-appengine/browse_thread/thread/be59798246c37fc0/321b1d0f09526018

Google的工程师说不是他们的问题,可能是yahoo那边屏蔽了从GAE ip的访问。由于我的cpedialog项目里使用了del.ico.us,决定还是探个究竟,于是给yahoo那边发了邮件过去,很快yahoo那边给了回信。

Delicious access from Google app engine
Chris ***<***@yahoo-inc.com>     Fri, Jul 31, 2009 at 12:43 AM
Hi,

Thanks for your report on problems accessing delicious feeds from Google app engine. I’ve contacted google directly on this to resolve the problem. Obviously I don’t have an exact timeframe but wanted to let you know we’re looking into it.

Thanks
Chris


快一个月过去了,yahoo总算把这个问题解决了。不过留给人的疑问是,为何偏偏只有google的服务器不能访问yahoo的资源呢?

Tags: delicious, google, appengine


Wednesday, April 08, 2009

Google App Engine java支持浮出水面

Google AppEngine 已经发布了 An Early Look at Java™ Language Support.
对java的支持已经成为事实,不知道又会有多少开发者加入到gae的阵营。

总之,是个好消息,扫了一遍文档,初步发现是基本的servlet容器,不知道现有的web框架是否直接支持,另外使用持续层使用JDO来实现对bigtable的操作。貌似JPA也支持,这样的话,像hibernate等framework的支持应该不会是太大的问题。

像python一样,用于对其他服务(像cache,google account,mail等)的访问,也有相应的java api. Google还不忘发布一个eclipse插件,不知道这个插件和android的那个有什么关系。另外这个servlet容器的jre和android的那个又有什么关系呢?

GAE对企业用户的吸引力又进一步增强了,GAE离挣钱的日子不远了。

对一个熟悉java web开发的人来说,学习成本几乎为零。

Cheers!

Tags: appengine, google


Friday, February 06, 2009

Sorry for delay release of cpedialog 2.0

I had a business trip to US in the last 3 month, so I hardly got time to focus on this project.
But I am back now, so I will continue to work on it.

Please don't be hesitated to give me suggestion or feedback. Thanks for your support.

BTW: I took a lot photos during my period in US, welcome to access my updated albums @ http://blog.cpedia.com/albums/yeli.piao

Happy Niu Year!

Tags: cpedialog, cpedia, python, blog, albums, appengine


Wednesday, July 30, 2008

cpedialog listed on the Google Appengine open source projects

cpedialog 已经被列在google appengine group的open sourc项目列表里面了。

http://groups.google.com/group/google-appengine/web/google-app-engine-open-source-projects

另外,我更新了cpedialog在google code上的项目介绍,增加了一些screenshots。

http://code.google.com/p/cpedialog/

cpedia在appgallery的地址是:
http://appgallery.appspot.com/about_app?app_id
=agphcHBnYWxsZXJ5chMLEgxBcHBsaWNhdGlvbnMY6B4M


Tags: cpedialog, python, appengine


Thursday, July 10, 2008

cpedialog程序开源

cpedialog已经落户到google code了,地址是 http://code.google.com/p/cpedialog/

如果你想在appengine上架设自己的站点,cpedialog是个不错的开始,尽管我们还没有发布测试版本,你仍然可以通过svn检出最新的代码。
 

# Non-members may check out a read-only working copy anonymously over HTTP.
svn checkout http://cpedialog.googlecode.com/svn/trunk/ cpedialog-read-only 
 

我们希望在第一个release时实现一些google service的整合,譬如picasaweb,calendar,docs等。

我们欢迎任何对appengine感兴趣,熟悉python的朋友加入cpedialog项目。有意者请给我发邮件:cpedia@gmail.com

 

Tags: cpedialog, appengine, python


Saturday, June 07, 2008

终于将博客迁移到google appengine

从对python一无所知,到将自己的博客程序(原为php)迁移到google的appengine仅仅用了不到一个星期的时间。


python真的很美,一切java里的经验都可以转移过来,我在实现基于google GqlQuery的分页类的时候几乎全盘借鉴以前实现的一个hibernate分页类。当然为了不重复造轮子,我还是扩展了django的paginator(最新版本的,而非appengine目前0.96的实现,0.96的ObjectPaginator已经不被赞成使用)。


虽然还有很多不完美的地方,尤其google Datastore的诸多限制,譬如数据一次最多只能fetch 1000条,cpu的使用限制,让我在将以前mysql里的数据导过来时费了很大一番周折。不过我会继续完善程序,谁叫我真的喜欢上了appengine和python呢。

Tags: appengine, python, django


Thursday, May 29, 2008

Google App Engine SDK

Google App Engine SDK 升级到1.1.0了,前几天还在排队的,今天突然发现可以直接用短信认证注册。

简单看了一下文档,app engine还是很诱人的。即使服务是收费了,但是对开发人员来说它的诱惑要远大于虚拟主机。

毕竟运算能力和带宽有了保证,而且google将会继续支持更多api,包括google已有服务(譬如gmail)。我都有准备把博客转到它上面的打算了。


 

Tags: appengine