<?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>feisley &#187; Google</title>
	<atom:link href="http://feisley.com/tag/google/feed/" rel="self" type="application/rss+xml" />
	<link>http://feisley.com</link>
	<description>programming with a side of life</description>
	<lastBuildDate>Thu, 15 Apr 2010 07:33:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Add a Little Privacy to Google Latitude</title>
		<link>http://feisley.com/2009/08/04/add-a-little-privacy-to-google-latitude/</link>
		<comments>http://feisley.com/2009/08/04/add-a-little-privacy-to-google-latitude/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 12:52:32 +0000</pubDate>
		<dc:creator>Jacob Feisley</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[LBS]]></category>
		<category><![CDATA[privacy]]></category>

		<guid isPermaLink="false">http://feisley.com/?p=3496</guid>
		<description><![CDATA[This title must sound very ironic given that the whole purpose of Google Latitude is to reduce privacy. I am not saying this is a bad thing, just that telling people where you are right now is less private than not telling them.
Recently, Google took the reduction of privacy a little further by allowing you [...]]]></description>
			<content:encoded><![CDATA[<p>This title must sound very ironic given that the whole purpose of Google Latitude is to reduce privacy. I am not saying this is a bad thing, just that telling people where you are right now is less private than not telling them.</p>
<p>Recently, Google took the reduction of privacy a little further by allowing you to setup a web site badge for Latitude. Up until this point, you could only share your location with select friends, however, now you can share it with the whole world via your website, blog, etc. I do use this, so you can spy on <a href="http://feisley.com/contact/location">my location</a> if you wish.</p>
<p><span id="more-3496"></span></p>
<p>But to the privacy elements shall we&#8230; When you generate a badge, Google gives you a snippet of HTML code that looks like this:</p>
<p><br class="spacer_" /></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- Google Public Location Badge --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;iframe</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;http://www.google.com/latitude/apps/badge/api?user=1234567890&amp;type=iframe&amp;maptype=roadmap&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;180&quot;</span> <span style="color: #000066;">frameborder</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;300&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/iframe<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #808080; font-style: italic;">&lt;!-- To disable location sharing, you *must* visit http://www.google.com/latitude/apps/badge and disable the Google Public Location badge. Removing this code snippet is not enough! --&gt;</span></pre></div></div>

<p>This works fine as is if you place it on your site, however, that number there (1234567890) is actually your API &#8220;username&#8221; and given inspecting this from your site, any user could simply place your position on their site or access the API by other programmatic methods. Notice Google&#8217;s warning that to disable it, you have to disable the badge globally via their site, but what if you just don&#8217;t want some people using your badge or plan to put it on a password protected area of your site&#8230; This is where a little privacy can help.</p>
<p>What I did for my site is use some PHP code to add a layer of abstraction to the Google Latitude API. It requests the content server side and displays it without ever revealing my Latitude user id. I then include my own PHP page within an iframe just as i would have the Google snippet and that&#8217;s it. Here is the simple PHP code to do this:</p>
<p><br class="spacer_" /></p>
<p><strong>location.php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://www.google.com/latitude/apps/badge/api?user=1234567890&amp;type=iframe&amp;maptype=roadmap&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">print</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>The resulting PHP page will generate a map that fills the entire browser. Then simply add an iframe that references that PHP script and your desired width and height and boom, no one can inspect your user id and you have added a little privacy back to Google Latitude.</p>
<p><br class="spacer_" /></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;iframe</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;location.php&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;650&quot;</span> <span style="color: #000066;">frameborder</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;480&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/iframe<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>P.S. For the advanced users out there you can also do some creative things with the &#8220;$content&#8221; object within PHP such as inject your own CSS or even remove elements of the badge that you don&#8217;t want on your site since Google gives very limited customization to this.</p>
]]></content:encoded>
			<wfw:commentRss>http://feisley.com/2009/08/04/add-a-little-privacy-to-google-latitude/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Voice and Asterisk</title>
		<link>http://feisley.com/2009/07/29/google-voice-and-asterisk/</link>
		<comments>http://feisley.com/2009/07/29/google-voice-and-asterisk/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 17:27:56 +0000</pubDate>
		<dc:creator>Jacob Feisley</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[asterisk]]></category>
		<category><![CDATA[Gizmo5]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[SIP]]></category>
		<category><![CDATA[voip]]></category>

		<guid isPermaLink="false">http://feisley.com/?p=3436</guid>
		<description><![CDATA[Many months back Paul Marks and I looked into how to integrate Google Voice and Asterisk. Inbound calling was simple as you direct your Google Voice account to a Gizmo5 number and Asterisk integrates with the open SIP standard that Gizmo5 uses.
However, our task was to be able to make outbound calls without the need [...]]]></description>
			<content:encoded><![CDATA[<p>Many months back <a href="http://pmarks.net">Paul Marks</a> and I looked into how to integrate Google Voice and Asterisk. Inbound calling was simple as you direct your Google Voice account to a Gizmo5 number and Asterisk integrates with the open SIP standard that Gizmo5 uses.</p>
<p>However, our task was to be able to make outbound calls without the need to use the web interface to place the call. What essentially had to happen is when you dialed a number on your SIP phone, Asterisk would have to talk to the Google Voice site and handle the call setup for you.</p>
<p><span id="more-3436"></span></p>
<p><strong>***UPDATE***: I worked with Ward Mundy of <a href="http://nerdvittles.com/">Nerd Vittles</a> who put togeather a complete solution for both Asterisk 1.4 and 1.6. Additionally we are now using<a href="http://code.google.com/p/pygooglevoice/"> pyGoogleVoice</a> which is a more complete library than Paul&#8217;s script below. For the full write up, check out: <a href="http://nerdvittles.com/?p=635">http://nerdvittles.com/?p=635</a></strong></p>
<p>Paul then created a Python AGI (Asterisk Gateway Interface) script. It integrates into your dial plan and allows for the call to be made. The logic flow is as follows:</p>
<ol>
<li>You pick up your SIP phone and make a call.</li>
<li>Asterisk receives your call and the google-voice-dialout.agi script is called.</li>
<li>The script contacts Google Voice and initiates a call based on the number passed to asterisk.</li>
<li>Google Voice then dials your Gizmo5 number which rings into Asterisk.</li>
<li>Asterisk identifies this call by its caller id and the script binds your outbound call and the incoming call from Google</li>
<li>Google proceeds to call out to your destination.</li>
<li>Call is connected!</li>
</ol>
<p>Now a few caveats to this approach. As Paul&#8217;s script is essentially<span style="text-decoration: line-through;"> screen scraping</span> using unpublished API&#8217;s to the Google Voice application, any changes made to their web API could break this script. (As he notes in the script comments) At any rate, at the time of writing it works and the script is available for download here, <a href="http://feisley.com/wp-content/uploads/2009/07/google-voice-dialout.agi">google-voice-dialout.agi</a>, or shown below for reference.</p>
<p>When I get some more time, I will post details how to integrate this into an Asterisk dialplan and other features.</p>
<p><br class="spacer_" /></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># google-voice-dialout.agi</span>
<span style="color: #808080; font-style: italic;"># Paul Marks (http://pmarks.net)</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># This is an Asterisk 1.6 script to place outgoing calls through Google Voice.</span>
<span style="color: #808080; font-style: italic;"># It will automatically sign into the web interface, and submit a click2call</span>
<span style="color: #808080; font-style: italic;"># request through your registered Gizmo number.  Asterisk can then answer</span>
<span style="color: #808080; font-style: italic;"># the incoming call, and Bridge() it into your original outgoing call.</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># I deduced the click2call sequence by using the &quot;Live HTTP Headers&quot; Firefox</span>
<span style="color: #808080; font-style: italic;"># plugin.  If the website changes too much, this script will probably stop</span>
<span style="color: #808080; font-style: italic;"># working, so don't use it for anything too important.</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># This assumes you've already configured Asterisk to receive Gizmo calls.</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># This rule will redirect outbound calls to this script:</span>
<span style="color: #808080; font-style: italic;">#   exten =&gt; _1NXXNXXXXXX,1,AGI(google-voice-dialout.agi)</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># This rule will connect the inbound GV/Gizmo calls:</span>
<span style="color: #808080; font-style: italic;">#   exten =&gt; s/6502650000,1,Bridge(${DB_DELETE(gv_dialout/channel)}, p)</span>
<span style="color: #808080; font-style: italic;">#              ^-- Put your 10-digit Google Voice number here.</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># To test this script from the command line without Asterisk, type the</span>
<span style="color: #808080; font-style: italic;"># following.  Be sure to type a few linefeeds at the end:</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;">#   $ ./google-voice-dialout.agi</span>
<span style="color: #808080; font-style: italic;">#   agi_channel:</span>
<span style="color: #808080; font-style: italic;">#   agi_dnid: 18004664411</span>
<span style="color: #808080; font-style: italic;">#</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Put your Google login and Gizmo number here:</span>
USERNAME = <span style="color: #483d8b;">&quot;username@gmail.com&quot;</span>
PASSWORD = <span style="color: #483d8b;">&quot;password&quot;</span>
GIZMO_NUMBER = <span style="color: #483d8b;">&quot;17475555555&quot;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">httplib</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">urllib</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">re</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">time</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> Error<span style="color: black;">&#40;</span><span style="color: #008000;">Exception</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">pass</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> ReadAgiEnvironment<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    env = <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span>
    <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #ff4500;">1</span>:
        line = <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdin</span>.<span style="color: #dc143c;">readline</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> line:
            <span style="color: #ff7700;font-weight:bold;">break</span>
        key, data = line.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">':'</span><span style="color: black;">&#41;</span>
        env<span style="color: black;">&#91;</span>key.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span> = data.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> env
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> SendAgi<span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span>:
    <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdout</span>.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span>
    <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdout</span>.<span style="color: black;">flush</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdin</span>.<span style="color: #dc143c;">readline</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> SimpleCookieJar<span style="color: black;">&#40;</span><span style="color: #008000;">object</span><span style="color: black;">&#41;</span>:
    cookie_re = <span style="color: #dc143c;">re</span>.<span style="color: #008000;">compile</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;(?i)set-cookie: (<span style="color: #000099; font-weight: bold;">\w</span>+)=([^;]+).*&quot;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">cookies</span> = <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> addCookies<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, response<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">for</span> header <span style="color: #ff7700;font-weight:bold;">in</span> response.<span style="color: black;">msg</span>.<span style="color: black;">headers</span>:
            m = <span style="color: #008000;">self</span>.<span style="color: black;">cookie_re</span>.<span style="color: black;">match</span><span style="color: black;">&#40;</span>header<span style="color: black;">&#41;</span>
            <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> m:
                <span style="color: #ff7700;font-weight:bold;">continue</span>
            <span style="color: #008000;">self</span>.<span style="color: black;">cookies</span><span style="color: black;">&#91;</span>m.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span> = m.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> get<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;; &quot;</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%s=%s&quot;</span> <span style="color: #66cc66;">%</span> kv <span style="color: #ff7700;font-weight:bold;">for</span> kv <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: black;">cookies</span>.<span style="color: black;">iteritems</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> GVClickToCall<span style="color: black;">&#40;</span><span style="color: #008000;">object</span><span style="color: black;">&#41;</span>:
    USER_AGENT = <span style="color: #483d8b;">&quot;google-voice-dialout.agi/1.1&quot;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, username, password, via, dial<span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">username</span> = username
        <span style="color: #008000;">self</span>.<span style="color: black;">password</span> = password
        <span style="color: #008000;">self</span>.<span style="color: black;">via</span> = via
        <span style="color: #008000;">self</span>.<span style="color: black;">dial</span> = dial
        <span style="color: #008000;">self</span>.<span style="color: black;">cj</span> = SimpleCookieJar<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">h</span> = <span style="color: #dc143c;">httplib</span>.<span style="color: black;">HTTPSConnection</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;www.google.com&quot;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">login</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">placeCall</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">logout</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> login<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #66cc66;">&gt;&gt;</span>sys.<span style="color: black;">stderr</span>, <span style="color: #483d8b;">&quot;Logging in.&quot;</span>
        postdata = <span style="color: #dc143c;">urllib</span>.<span style="color: black;">urlencode</span><span style="color: black;">&#40;</span><span style="color: black;">&#123;</span> <span style="color: #483d8b;">&quot;Email&quot;</span>: <span style="color: #008000;">self</span>.<span style="color: black;">username</span>,
                                      <span style="color: #483d8b;">&quot;Passwd&quot;</span>: <span style="color: #008000;">self</span>.<span style="color: black;">password</span> <span style="color: black;">&#125;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">doRequest</span><span style="color: black;">&#40;</span>
            method=<span style="color: #483d8b;">&quot;POST&quot;</span>, url=<span style="color: #483d8b;">&quot;/accounts/ServiceLoginAuth&quot;</span>,
            body=postdata,
            headers=<span style="color: black;">&#123;</span> <span style="color: #483d8b;">&quot;Content-Type&quot;</span>: <span style="color: #483d8b;">&quot;application/x-www-form-urlencoded&quot;</span> <span style="color: black;">&#125;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;"># Start at https://www.google.com/voice, and collect cookies as we</span>
        <span style="color: #808080; font-style: italic;"># follow all the redirects.</span>
        PREFIX = <span style="color: #483d8b;">&quot;https://www.google.com/&quot;</span>
        location = <span style="color: #483d8b;">&quot;/voice&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">xrange</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">5</span><span style="color: black;">&#41;</span>:
            response, html = <span style="color: #008000;">self</span>.<span style="color: black;">doRequest</span><span style="color: black;">&#40;</span>
                method=<span style="color: #483d8b;">&quot;GET&quot;</span>, url=location,
                headers=<span style="color: black;">&#123;</span><span style="color: black;">&#125;</span><span style="color: black;">&#41;</span>
&nbsp;
            location = response.<span style="color: black;">getheader</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;location&quot;</span><span style="color: black;">&#41;</span>
            <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> location:
                <span style="color: #808080; font-style: italic;"># No more redirects, yay!</span>
                <span style="color: #ff7700;font-weight:bold;">break</span>
&nbsp;
            <span style="color: #808080; font-style: italic;"># All redirects should fall within the same domain.</span>
            <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> location.<span style="color: black;">startswith</span><span style="color: black;">&#40;</span>PREFIX<span style="color: black;">&#41;</span>:
                <span style="color: #ff7700;font-weight:bold;">raise</span> Error<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Unexpected redirect: %s&quot;</span> <span style="color: #66cc66;">%</span> location<span style="color: black;">&#41;</span>
            location = location<span style="color: black;">&#91;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>PREFIX<span style="color: black;">&#41;</span>-<span style="color: #ff4500;">1</span>:<span style="color: black;">&#93;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;"># Scrape magic _rnr_se value from the HTML.</span>
        m = <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'name=&quot;_rnr_se&quot; type=&quot;hidden&quot; value=&quot;([^&quot;]+)&quot;'</span>, html<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> m:
            <span style="color: #ff7700;font-weight:bold;">raise</span> Error<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Can't find _rnr_se.  Not logged in?&quot;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">magic_rnr_se</span> = m.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> placeCall<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #66cc66;">&gt;&gt;</span>sys.<span style="color: black;">stderr</span>, <span style="color: #483d8b;">&quot;Calling %s via %s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">dial</span>, <span style="color: #008000;">self</span>.<span style="color: black;">via</span><span style="color: black;">&#41;</span>
        postdata = <span style="color: #dc143c;">urllib</span>.<span style="color: black;">urlencode</span><span style="color: black;">&#40;</span><span style="color: black;">&#123;</span> <span style="color: #483d8b;">&quot;outgoingNumber&quot;</span>: <span style="color: #008000;">self</span>.<span style="color: black;">dial</span>,
                                      <span style="color: #483d8b;">&quot;forwardingNumber&quot;</span>: <span style="color: #008000;">self</span>.<span style="color: black;">via</span>,
                                      <span style="color: #483d8b;">&quot;_rnr_se&quot;</span>: <span style="color: #008000;">self</span>.<span style="color: black;">magic_rnr_se</span> <span style="color: black;">&#125;</span><span style="color: black;">&#41;</span>
        response, http = <span style="color: #008000;">self</span>.<span style="color: black;">doRequest</span><span style="color: black;">&#40;</span>
            method=<span style="color: #483d8b;">&quot;POST&quot;</span>, url=<span style="color: #483d8b;">&quot;/voice/call/connect&quot;</span>,
            body=postdata,
            headers=<span style="color: black;">&#123;</span> <span style="color: #483d8b;">&quot;Content-Type&quot;</span>: <span style="color: #483d8b;">&quot;application/x-www-form-urlencoded&quot;</span> <span style="color: black;">&#125;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #66cc66;">&gt;&gt;</span>sys.<span style="color: black;">stderr</span>, <span style="color: #483d8b;">&quot;Dial response:&quot;</span>, http
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> logout<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">doRequest</span><span style="color: black;">&#40;</span>
            method=<span style="color: #483d8b;">&quot;GET&quot;</span>, url=<span style="color: #483d8b;">&quot;/accounts/Logout&quot;</span>,
            headers=<span style="color: black;">&#123;</span> <span style="color: #483d8b;">&quot;Connection&quot;</span>: <span style="color: #483d8b;">&quot;close&quot;</span> <span style="color: black;">&#125;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #66cc66;">&gt;&gt;</span>sys.<span style="color: black;">stderr</span>, <span style="color: #483d8b;">&quot;Logged out.&quot;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> doRequest<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, headers, <span style="color: #66cc66;">**</span>kw<span style="color: black;">&#41;</span>:
        headers<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;User-agent&quot;</span><span style="color: black;">&#93;</span> = <span style="color: #008000;">self</span>.<span style="color: black;">USER_AGENT</span>
        headers<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;Cookie&quot;</span><span style="color: black;">&#93;</span> = <span style="color: #008000;">self</span>.<span style="color: black;">cj</span>.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">h</span>.<span style="color: black;">request</span><span style="color: black;">&#40;</span>headers=headers, <span style="color: #66cc66;">**</span>kw<span style="color: black;">&#41;</span>
        response = <span style="color: #008000;">self</span>.<span style="color: black;">h</span>.<span style="color: black;">getresponse</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">cj</span>.<span style="color: black;">addCookies</span><span style="color: black;">&#40;</span>response<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> response, response.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    env = ReadAgiEnvironment<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #66cc66;">&gt;&gt;</span>sys.<span style="color: black;">stderr</span>, env
&nbsp;
    agi_channel = env<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;agi_channel&quot;</span><span style="color: black;">&#93;</span>
    agi_dnid = env<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;agi_dnid&quot;</span><span style="color: black;">&#93;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;"># Write the channel ID to Asterisk's database, so it can be accessed</span>
    <span style="color: #808080; font-style: italic;"># by the incoming call when it arrives.</span>
    SendAgi<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;database put gv_dialout channel %s&quot;</span> <span style="color: #66cc66;">%</span> agi_channel<span style="color: black;">&#41;</span>
&nbsp;
    SendAgi<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;answer&quot;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">try</span>:
        GVClickToCall<span style="color: black;">&#40;</span>username=USERNAME, password=PASSWORD,
                      dial=agi_dnid, via=GIZMO_NUMBER<span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;"># Asterisk should patch in the incoming call while we're asleep.</span>
        <span style="color: #dc143c;">time</span>.<span style="color: black;">sleep</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">10</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">finally</span>:
        SendAgi<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;hangup&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">'__main__'</span>:
    main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://feisley.com/2009/07/29/google-voice-and-asterisk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google App Engine</title>
		<link>http://feisley.com/2008/04/08/google-app-engine/</link>
		<comments>http://feisley.com/2008/04/08/google-app-engine/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 03:41:19 +0000</pubDate>
		<dc:creator>Jacob Feisley</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[App Engine]]></category>
		<category><![CDATA[PyAMF]]></category>

		<guid isPermaLink="false">http://feisley.com/?p=32</guid>
		<description><![CDATA[
Last night, Google launched App Engine which allows developers to create web applications and publish them on Google&#8217;s infrastructure. The exciting part of the App Engine in my eyes is that the language you use to develop on it is Python. Google provides many API&#8217;s to interface the Python programming language with the various services [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-thumbnail wp-image-33" title="Google App Engine" src="http://feisley.com/wp-content/uploads/2008/04/app-engine-150x150.png" alt="" width="150" height="150" /></p>
<p>Last night, Google launched <a href="http://appengine.google.com">App Engine</a> which allows developers to create web applications and publish them on Google&#8217;s infrastructure. The exciting part of the App Engine in my eyes is that the language you use to develop on it is Python. Google provides many API&#8217;s to interface the Python programming language with the various services they offer. You can authenticate via Google accounts, use Bigtable to store data, and use Google Aps to bind your application to your own domain. They opened the initial &#8220;Preview Release&#8221; to the first 10,000 developers to sign up. From the looks of it, those 10,000 spots filled up within the first few hours of the launch.</p>
<p>I was fortunate to be one of the first to sign up and got my account last night. I created a basic hello world application to test and overall the system seems very easy to use. My demo is at <a href="http://labs.appspot.com">http://labs.appspot.com</a>.</p>
<p>I also created an account for the <a href="http://pyamf.org">PyAMF</a> project and we were able to get a PyAMF echo server running on App Engine. It is currently located at: <a href="http://ae.pyamf.org">http://ae.pyamf.org</a> We are continuing to work with it today and tomorrow to write up some examples and a How-to to get people started quickly. We will continue to add more examples to the site as time progresses and we get everything documented.</p>
]]></content:encoded>
			<wfw:commentRss>http://feisley.com/2008/04/08/google-app-engine/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

