Create a gist now

Instantly share code, notes, and snippets.

@janithl /feed.php
Last active Nov 26, 2015

What would you like to do?
PHP script for turning your Google+ feeds into valid RSS. You need to edit a couple of places but I'm sure you're smart enough to figure that out... :)
header('Content-type: text/xml');
$gendate = date('r', time());
$config = array(
'gplusid' => '116783522121096138585',
'gplusname' => 'Janith Leanage',
'hosturl' => ''
$data = file_get_contents("[1,2,$config['gplusid'],null,null,10,null,\"\",[]]");
//remove first shits
$parsed = str_replace(")]}'", "", $data);
$parsed = str_replace('[,' , '["",' , $parsed);
$parsed = str_replace(',,' , ',"",' , $parsed);
$parsed = str_replace(',,' , ',"",' , $parsed);
$parsed_data = json_decode($parsed);
$stream = $parsed_data[0][1][0];
echo '<?xml version="1.0" encoding="UTF-8"?>';
<rss version="2.0"
<title><?= $config['gplusname'] ?> on Google+</title>
<atom:link href="<?= $config['hosturl'] ?>" rel="self" type="application/rss+xml" />
<link><?= $config['gplusid'] ?>/posts</link>
<description><?= $config['gplusname'] ?> has a Google+ account, and he's making an RSS feed of his postings there</description>
<lastBuildDate><?= $gendate ?></lastBuildDate>
<generator><?= $config['gplusname'] ?>'s G+ RSS generator</generator>
<?php for($a = 0; $a < 10; $a++): ?>
<title><?= $stream[$a][4] ?></title>
<link><?= $stream[$a][21] ?></link>
<comments><?= $stream[$a][21] ?>#comments</comments>
<pubDate><?= date('r', (int)($stream[$a][5] / 1000) ?></pubDate>
<dc:creator><?= $config['gplusname'] ?></dc:creator>
<description><![CDATA[<?= isset($stream[$a][11][0][3]) ? $stream[$a][11][0][3] : '' ?>]]></description>
<?php endfor; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment