<?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>Jonas Nordström &#187; googlereader</title>
	<atom:link href="http://jonasnordstrom.se/tag/googlereader/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonasnordstrom.se</link>
	<description>Teknik och media</description>
	<lastBuildDate>Fri, 04 May 2012 09:59:51 +0000</lastBuildDate>
	<language>sv-SE</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>GR2WP &#8211; Google reader shared items till WordPress</title>
		<link>http://jonasnordstrom.se/gr2wp-google-reader-shared-items-till-wordpress/</link>
		<comments>http://jonasnordstrom.se/gr2wp-google-reader-shared-items-till-wordpress/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 14:27:03 +0000</pubDate>
		<dc:creator>jonas</dc:creator>
				<category><![CDATA[Teknik]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[googlereader]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[xmlrpc]]></category>

		<guid isPermaLink="false">http://jonasnordstrom.se/?p=35</guid>
		<description><![CDATA[I kategorin Tips så delar jag med mig av intressanta inlägg som jag hittat via mina RSS-flöden i Google Reader. Det finns flera andra som har liknande funktion på sina bloggar, de använder då exempelvis FeedWordPress, SharedItems2WP eller WP-o-Matic. Av olika anledningar passade ingen av dessa lösningar mig perfekt, mest för att jag ville ha [...]]]></description>
			<content:encoded><![CDATA[<p>I kategorin <a href="/category/tips/">Tips</a> så delar jag med mig av intressanta inlägg som jag hittat via mina RSS-flöden i Google Reader.</p>

<p>Det finns flera andra som har liknande funktion på sina bloggar, de använder då exempelvis <a href="http://wordpress.org/extend/plugins/feedwordpress/">FeedWordPress</a>, <a href="http://github.com/jardenberg/SharedItems2WP/tree/master">SharedItems2WP</a> eller <a href="http://wordpress.org/extend/plugins/wp-o-matic/">WP-o-Matic</a>. Av olika anledningar passade ingen av dessa lösningar mig perfekt, mest för att jag ville ha full kontroll över flödet och för att det var så länge sen jag programmerade i perl &#8230;</p>

<p>Som jag nyss avslöjade, så skrev jag alltså ett perl-script som hämtar min shared items-feed från google reader (via <a href="http://search.cpan.org/~tima/XML-Atom-Syndication-0.942/lib/XML/Atom/Syndication/Feed.pm">XML::Atom::Syndication::Feed</a>) och sen trycker jag in en post med de senaste bloggtipsen i WordPress (via <a href="http://search.cpan.org/~mkutter/SOAP-Lite-0.710.08/lib/XMLRPC/Lite.pm">XMLRPC::Lite</a>).</p>

<p>Effekten blir den här.</p>

<p>Gå till Google reader, hitta ett intressant inlägg och välj &#8220;Share with note&#8221;.</p>

<div id="attachment_41" class="wp-caption alignnone" style="width: 580px"><a href="http://jonasnordstrom.se/wp-content/uploads/2009/07/Bild-39.jpg"><img class="size-medium wp-image-41" title="google reader" src="http://jonasnordstrom.se/wp-content/uploads/2009/07/Bild-39-580x272.jpg" alt="Share with note i google reader" width="580" height="272" /></a><p class="wp-caption-text">Share with note i google reader</p></div>

<p>Lägg till en anteckning och spara.</p>

<p>Kör sen perlscriptet gr2wp.pl (Google Reader To WordPress). 
Då skapas ett WP-inlägg med alla nya utdelade bloggposter.</p>

<div id="attachment_45" class="wp-caption alignnone" style="width: 580px"><a href="http://jonasnordstrom.se/wp-content/uploads/2009/07/jonas-tipsar-exempel-1.jpg"><img src="http://jonasnordstrom.se/wp-content/uploads/2009/07/jonas-tipsar-exempel-1-580x349.jpg" alt="Resultatet i WordPress" title="jonas tipsar" width="580" height="349" class="size-medium wp-image-45" /></a><p class="wp-caption-text">Resultatet i WordPress</p></div>

<p><a href="/category/tips/">Alla &#8220;Jonas tipsar&#8221;-inlägg</a></p>

<p>Här kommer perlscriptet. Du får gärna använda och modifiera det helt fritt. Jag har utgått från ett script som postade <a href="http://www.onfocus.com/2009/05/4194">google-reader shared items till delicious</a>.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
</pre></td><td class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> LWP<span style="color: #339933;">::</span><span style="color: #006600;">Simple</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> XML<span style="color: #339933;">::</span><span style="color: #006600;">Atom</span><span style="color: #339933;">::</span><span style="color: #006600;">Syndication</span><span style="color: #339933;">::</span><span style="color: #006600;">Feed</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> XMLRPC<span style="color: #339933;">::</span><span style="color: #006600;">Lite</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> XML<span style="color: #339933;">::</span><span style="color: #006600;">XPath</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> WordPress<span style="color: #339933;">::</span><span style="color: #006600;">XMLRPC</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> HTML<span style="color: #339933;">::</span><span style="color: #006600;">Entities</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Time<span style="color: #339933;">::</span><span style="color: #006600;">Local</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">######## CONFIGURATION ########</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$debug</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;"># Your Google Shared Items Feed URL</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$feed_url</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'yourgoogleshareditemsfeedurl'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># A local file location for the feed</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$feed_file</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'/path/to/localfeedfile.xml'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Timestamp file</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$ts_file</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;/path/to/gr2wp_timestamp.lis&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Wordpress post title</span>
<span style="color: #0000ff;">$wp_title</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;post title&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Wordpress post categories (example: ['Fashion','Beauty'])</span>
<span style="color: #666666; font-style: italic;"># (The categories must exist before posting)</span>
<span style="color: #0000ff;">@wp_categories</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #ff0000;">'category'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Wordpress user</span>
<span style="color: #0000ff;">$wp_user</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'username'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Wordpress password</span>
<span style="color: #0000ff;">$wp_pwd</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'password'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Wordpress proxy (URL to xmlrpc.php, don't forget to activate xmlrpc protocol in blog!)</span>
<span style="color: #0000ff;">$wp_proxy</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'http://sitename/xmlrpc.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">######## END CONFIGURATION ########</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># start time handling</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@now</span> <span style="color: #339933;">=</span> <span style="color: #000066;">localtime</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$time</span> <span style="color: #339933;">=</span> timelocal<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@now</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Subtract one week (default if no timestamp file found)</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$default_start</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$time</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">7</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">24</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">60</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$start_date</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># fetch last startdate or, if not found, pick a date one week ago</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>e <span style="color: #0000ff;">$ts_file</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">open</span> FP<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt;$ts_file&quot;</span> <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Could not open file $ts_file: $! <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$start_date</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">close</span> FP<span style="color: #339933;">;</span>
	<span style="color: #000066;">chomp</span> <span style="color: #0000ff;">$start_date</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$start_date</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/\s//g</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #0000ff;">$start_date</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$default_start</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Start date: &quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$start_date</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$debug</span><span style="color: #339933;">;</span>
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;now: &quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$time</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$debug</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Set the google reader namespace URI</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$gr</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'http://www.google.com/schemas/reader/atom/'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#snag a local copy of the shared items feed</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$status</span> <span style="color: #339933;">=</span> getstore<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$feed_url</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$feed_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Error $status fetching the Google Reader feed.&quot;</span> <span style="color: #b1b100;">unless</span> is_success<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$status</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;"># Init the wordpress API</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$o</span> <span style="color: #339933;">=</span> WordPress<span style="color: #339933;">::</span><span style="color: #006600;">XMLRPC</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>new<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
username <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$wp_user</span><span style="color: #339933;">,</span>
password <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$wp_pwd</span><span style="color: #339933;">,</span>
proxy <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$wp_proxy</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#parse the shared items feed</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$feed</span> <span style="color: #339933;">=</span> XML<span style="color: #339933;">::</span><span style="color: #006600;">Atom</span><span style="color: #339933;">::</span><span style="color: #006600;">Syndication</span><span style="color: #339933;">::</span><span style="color: #006600;">Feed</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$feed_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@entries</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$feed</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">entries</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># loop through items in the feed</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$buf</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;&lt;ul&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$post_count</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$entry</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@entries</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;"># grab the title, link, and source title</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$postTitle</span> <span style="color: #339933;">=</span> encode_entities<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">title</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">body</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$postLink</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">link</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">href</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$sourceTitle</span> <span style="color: #339933;">=</span> encode_entities<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">source</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">title</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">body</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># get the time this item was shared</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$shareTime</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">get_attribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$gr</span><span style="color: #339933;">,</span><span style="color: #ff0000;">'crawl-timestamp-msec'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># convert from milliseconds to seconds</span>
	<span style="color: #0000ff;">$shareTime</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$shareTime</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">1000</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># skip item if it was shared before the start date</span>
	<span style="color: #b1b100;">next</span> <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$shareTime</span> <span style="color: #339933;">&lt;</span> <span style="color: #0000ff;">$start_date</span><span style="color: #339933;">;</span>
  	<span style="color: #0000ff;">$post_count</span><span style="color: #339933;">++;</span>
 	<span style="color: #666666; font-style: italic;">#grab any notes</span>
 	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$xp</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$entry</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>as_xml<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># get the notes, this should probably be simplified ...</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$notes</span> <span style="color: #339933;">=</span> encode_entities<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$1</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\2</span>00-<span style="color: #000099; font-weight: bold;">\3</span>77&quot;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$xp</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">m/annotation&gt;(.*?)&lt;\/content&gt;/</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># Remove the &quot;CDATA&quot; bit, if present</span>
	<span style="color: #0000ff;">$notes</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$1</span> <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$notes</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">m/&lt;!--\[CDATA\[(.*)\]\]--&gt;/s</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Title: $postTitle<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$debug</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Link: $postLink<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$debug</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Source: $sourceTitle<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$debug</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;"># Create the post content</span>
	<span style="color: #0000ff;">$buf</span> <span style="color: #339933;">.=</span> <span style="color: #ff0000;">&quot;&lt;li class=&quot;</span><span style="color: #0000ff;">\&amp;quot</span><span style="color: #339933;">;</span>tipsitem<span style="color: #0000ff;">\&amp;quot</span><span style="color: #339933;">;</span><span style="color: #ff0000;">&quot;&gt;$sourceTitle: &lt;a href=&quot;</span><span style="color: #0000ff;">$postLink</span><span style="color: #ff0000;">&quot;&gt;$postTitle&lt;/a&gt;&lt;/li&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$notes</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #0000ff;">$buf</span> <span style="color: #339933;">.=</span> <span style="color: #ff0000;">&quot;&lt;blockquote&gt;&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #0000ff;">$buf</span> <span style="color: #339933;">.=</span> <span style="color: #ff0000;">&quot;$notes&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #0000ff;">$buf</span> <span style="color: #339933;">.=</span> <span style="color: #ff0000;">&quot;&lt;/blockquote&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #0000ff;">$buf</span> <span style="color: #339933;">.=</span> <span style="color: #ff0000;">&quot;&lt;/ul&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#Delete the local copy of the feed</span>
<span style="color: #000066;">unlink</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$feed_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># timestamp</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$ymd</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">sub</span><span style="color: #009900;">&#123;</span><span style="color: #000066;">sprintf</span> <span style="color: #ff0000;">'%04d-%02d-%02d'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">$_</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1900</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$_</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$_</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span><span style="color: #009900;">&#40;</span><span style="color: #000066;">localtime</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$content_hashref</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$content_hashref</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>title<span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;$wp_title - $ymd&quot;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$content_hashref</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>categories<span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">@wp_categories</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$content_hashref</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>description<span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$buf</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Post to wordpress</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$post_count</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #0000ff;">$o</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">newPost</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$content_hashref</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066;">open</span> FP<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&gt;$ts_file&quot;</span> <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Could not open file $ts_file for writing: $!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">print</span> FP <span style="color: #0000ff;">$time</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">close</span> FP<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;No posts<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Debugging purposes, write post to local file gr2wp_debug.lis</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$debug</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">open</span> OFP<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&gt;gr2wp_debug.lis&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">print</span> OFP <span style="color: #0000ff;">$buf</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">close</span> OFP<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<p>För enkelhetens skull kör jag perl-scriptet en gång om dagen, via crontab.</p>
 <p><a href="http://jonasnordstrom.se/?flattrss_redirect&amp;id=35&amp;md5=ae9ed79c41f433f61ef4faadbd1633ef" title="Flattr" target="_blank"><img src="http://jonasnordstrom.se/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://jonasnordstrom.se/gr2wp-google-reader-shared-items-till-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=windyjonas&amp;popout=1&amp;url=http%3A%2F%2Fjonasnordstrom.se%2Fgr2wp-google-reader-shared-items-till-wordpress%2F&amp;language=sv_SE&amp;category=text&amp;title=GR2WP+%26%238211%3B+Google+reader+shared+items+till+WordPress&amp;description=I+kategorin+Tips+s%C3%A5+delar+jag+med+mig+av+intressanta+inl%C3%A4gg+som+jag+hittat+via+mina+RSS-fl%C3%B6den+i+Google+Reader.+Det+finns+flera+andra+som+har+liknande+funktion+p%C3%A5+sina...&amp;tags=googlereader%2Cperl%2Cwordpress%2Cxmlrpc%2Cblog" type="text/html" />
	</item>
	</channel>
</rss>

