<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>hi, it&#39;s mike</title>
    <link>https://mike.puddingtime.org/tags/instapaper/</link>
    <description>Recent content on hi, it&#39;s mike</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <managingEditor>mike@puddingtime.org (mike)</managingEditor>
    <webMaster>mike@puddingtime.org (mike)</webMaster>
    <copyright>© 2026, mike</copyright>
    <lastBuildDate>Tue, 10 Feb 2009 06:30:23 +0000</lastBuildDate>
    <atom:link href="https://mike.puddingtime.org/tags/instapaper/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Save to Instapaper from NetNewsWire</title>
      <link>https://mike.puddingtime.org/posts/2009-02-10-save-to-instapaper-from-netnewswire/</link>
      <pubDate>Tue, 10 Feb 2009 06:30:23 +0000</pubDate><author>mike@puddingtime.org (mike)</author>
      <guid>https://mike.puddingtime.org/posts/2009-02-10-save-to-instapaper-from-netnewswire/</guid>
      
      <description>At some point some applescripts I found for posting from NetNewsWire to Instapaper broke. A few days ago, during one of my rare jaunts to the bottom of the Instapaper homepage I came across a reference to the Read Later API. I wrote it down on my todo list as a thing to deal with over lunch some …</description>
      <content:encoded><![CDATA[<p>At some point some applescripts I found for posting from NetNewsWire to <a href="http://instapaper.com">Instapaper</a> broke. A few days ago, during one of my rare jaunts to the bottom of the Instapaper homepage I came across a reference to the <a href="http://blog.instapaper.com/post/73123968/read-later-api">Read Later API</a>. I wrote it down on my todo list as a thing to deal with over lunch some day.</p>
<p>The API involves nothing more than an HTTP request with a half-dozen parameters, a few of which are optional. I stopped shy of simulating the wonderful Instapaper response popup, settling instead on a system beep:</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">&lt;p&gt;</span></span></code></pre></div>
<p>[sourcecode language=&lsquo;ruby&rsquo;]</p>
<p>!/usr/bin/env ruby</p>
<p>require &lsquo;rubygems&rsquo;</p>
<p>require &lsquo;open-uri&rsquo;</p>
<p>require &lsquo;openssl&rsquo;</p>
<p>require &lsquo;appscript&rsquo;</p>
<p>include Appscript</p>
<p>require &lsquo;osax&rsquo;</p>
<p>include OSAX</p>
<p>username = &ldquo;USERNAME&rdquo;</p>
<p>password = &ldquo;PASSWORD&rdquo;</p>
<p>nnw = app(&ldquo;NetNewsWire&rdquo;)</p>
<p>OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE</p>
<p>item = nnw.selectedHeadline.get</p>
<p>url = URI.encode(item.URL.get).gsub!(/^htt.+?///, &ldquo;&rdquo;)</p>
<p>title = item.title.get</p>
<p>description = item.description.get.gsub!(/&lt;.+?&gt;/, &ldquo;&rdquo;)</p>
<p>selection = description.length &gt; 150 ? description.slice(0,150) + &quot; ...&quot; : description</p>
<p>base_url = &ldquo;https://www.instapaper.com/api/add?&rdquo;</p>
<p>params = &ldquo;title={title}&amp;url={url}&amp;username={username}&amp;password={password}&amp;selection={selection}&rdquo;</p>
<p>post_url = &ldquo;{base_url}{params}&rdquo;</p>
<p>begin</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">response = open\(URI\.encode\(post\_url\)\)</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">osax\.beep</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">or display a dialog:</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">osax\.display\_dialog\(&#34;Posted\.&#34;\)</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">rescue =&gt; ex</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">case ex\.message\.gsub\(/\\s\.\*/, &#34;&#34;\)</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code> ```
</code></pre>
<p>when &ldquo;400&rdquo; : message = &ldquo;Error: Bad Request.&rdquo;</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">     ```
</span></span><span class="line"><span class="cl">when &#34;403&#34; : message = &#34;Bad password/username\.&#34;</span></span></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<pre><code> ```
</code></pre>
<p>when &ldquo;500&rdquo; : message = &ldquo;Server error.&rdquo;</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<p>end</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"></code></pre></div>
<p>osax.display_dialog(message)</p>






<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">end
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">\[/sourcecode\]</span></span></code></pre></div>
</p>
```
<p>#appscript #instapaper #netnewswire #ruby</p>
<p><em><a href="mailto:mike@puddingtime.org?subject=Re%3A%20Save%20to%20Instapaper%20from%20NetNewsWire">Drop a line about this</a>.</em></p>]]></content:encoded>
    </item>
  </channel>
</rss>
