config.php
· 190 B · PHP
Raw
<?php
$base = 'https://rss.do.kdy.ch/';
$user = '<USER>';
$pass = '<PASS>';
$exclude = [
'YouTube',
'YouTube (VT)',
'YouTube Subscriptions Feed',
'Patreon'
];
| 1 | <?php |
| 2 | $base = 'https://rss.do.kdy.ch/'; |
| 3 | $user = '<USER>'; |
| 4 | $pass = '<PASS>'; |
| 5 | $exclude = [ |
| 6 | 'YouTube', |
| 7 | 'YouTube (VT)', |
| 8 | 'YouTube Subscriptions Feed', |
| 9 | 'Patreon' |
| 10 | ]; |
cron.php
· 1.5 KiB · PHP
Raw
<?php
require_once __DIR__ . '/config.php';
// First, login
$cLogin = curl_init($base . 'api/greader.php/accounts/ClientLogin?Email=' . $user . '&Passwd=' . $pass);
curl_setopt($cLogin, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($cLogin, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($cLogin, CURLOPT_RETURNTRANSFER, true);
$keys = curl_exec($cLogin);
curl_close($cLogin);
// Then we fetch our feed (max 1000 elements) excluding those marked as read
$ch = curl_init($base . 'api/greader.php/reader/api/0/stream/contents/reading-list?n=1000&xt=user/-/state/com.google/read');
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization:GoogleLogin ' . str_replace('Auth=','auth=', explode("\n", $keys)[2])
));
$out = curl_exec($ch);
$json = json_decode($out);
curl_close($ch);
// We'll now go thru the results
$out = [];
foreach ($json->items as $item) {
// If the source matches the exclude list, ignore
if (in_array($item->origin->title, $exclude)) continue;
// If it has a Newsletters label, ignore
if (in_array('user/-/label/Newsletters', $item->categories)) continue;
$u = $item->alternate[0]->href;
$out[] = array(
'id' => $item->id,
'title' => $item->title,
'source' => $item->origin->title,
'link' => empty($u) ? $base . 'i/' : $u
);
}
// And we save the results as json
file_put_contents('public/rss.json', json_encode($out));
| 1 | <?php |
| 2 | require_once __DIR__ . '/config.php'; |
| 3 | |
| 4 | // First, login |
| 5 | $cLogin = curl_init($base . 'api/greader.php/accounts/ClientLogin?Email=' . $user . '&Passwd=' . $pass); |
| 6 | curl_setopt($cLogin, CURLOPT_SSL_VERIFYHOST, 0); |
| 7 | curl_setopt($cLogin, CURLOPT_SSL_VERIFYPEER, 0); |
| 8 | curl_setopt($cLogin, CURLOPT_RETURNTRANSFER, true); |
| 9 | $keys = curl_exec($cLogin); |
| 10 | curl_close($cLogin); |
| 11 | |
| 12 | // Then we fetch our feed (max 1000 elements) excluding those marked as read |
| 13 | $ch = curl_init($base . 'api/greader.php/reader/api/0/stream/contents/reading-list?n=1000&xt=user/-/state/com.google/read'); |
| 14 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
| 15 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
| 16 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 17 | curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
| 18 | 'Authorization:GoogleLogin ' . str_replace('Auth=','auth=', explode("\n", $keys)[2]) |
| 19 | )); |
| 20 | $out = curl_exec($ch); |
| 21 | $json = json_decode($out); |
| 22 | curl_close($ch); |
| 23 | |
| 24 | // We'll now go thru the results |
| 25 | $out = []; |
| 26 | foreach ($json->items as $item) { |
| 27 | // If the source matches the exclude list, ignore |
| 28 | if (in_array($item->origin->title, $exclude)) continue; |
| 29 | // If it has a Newsletters label, ignore |
| 30 | if (in_array('user/-/label/Newsletters', $item->categories)) continue; |
| 31 | |
| 32 | $u = $item->alternate[0]->href; |
| 33 | $out[] = array( |
| 34 | 'id' => $item->id, |
| 35 | 'title' => $item->title, |
| 36 | 'source' => $item->origin->title, |
| 37 | 'link' => empty($u) ? $base . 'i/' : $u |
| 38 | ); |
| 39 | } |
| 40 | |
| 41 | // And we save the results as json |
| 42 | file_put_contents('public/rss.json', json_encode($out)); |