|
@@ -742,12 +742,12 @@ final class GReaderAPI {
|
|
|
|
|
|
|
|
// Note: This section must be streamed to avoid memory issues with large responses
|
|
// Note: This section must be streamed to avoid memory issues with large responses
|
|
|
echo <<<TXT
|
|
echo <<<TXT
|
|
|
-{
|
|
|
|
|
- "id": "user/-/state/com.google/reading-list",
|
|
|
|
|
- "updated": $time,
|
|
|
|
|
- "items": [
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ "id": "user/-/state/com.google/reading-list",
|
|
|
|
|
+ "updated": $time,
|
|
|
|
|
+ "items": [
|
|
|
|
|
|
|
|
-TXT;
|
|
|
|
|
|
|
+ TXT;
|
|
|
foreach ($items as $item) {
|
|
foreach ($items as $item) {
|
|
|
if (!is_array($item) || empty($item)) {
|
|
if (!is_array($item) || empty($item)) {
|
|
|
continue;
|
|
continue;
|
|
@@ -762,19 +762,19 @@ TXT;
|
|
|
}
|
|
}
|
|
|
echo <<<'TXT'
|
|
echo <<<'TXT'
|
|
|
|
|
|
|
|
- ]
|
|
|
|
|
-TXT;
|
|
|
|
|
|
|
+ ]
|
|
|
|
|
+ TXT;
|
|
|
if ($nbItems >= $count && $lastEntryId > 0) {
|
|
if ($nbItems >= $count && $lastEntryId > 0) {
|
|
|
echo <<<TXT
|
|
echo <<<TXT
|
|
|
-,
|
|
|
|
|
- "continuation": "$lastEntryId"
|
|
|
|
|
-TXT;
|
|
|
|
|
|
|
+ ,
|
|
|
|
|
+ "continuation": "$lastEntryId"
|
|
|
|
|
+ TXT;
|
|
|
}
|
|
}
|
|
|
echo <<<'TXT'
|
|
echo <<<'TXT'
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
-TXT;
|
|
|
|
|
|
|
+ TXT;
|
|
|
exit();
|
|
exit();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -786,6 +786,8 @@ TXT;
|
|
|
// https://github.com/mihaip/google-reader-api/blob/master/wiki/ApiStreamItemsIds.wiki
|
|
// https://github.com/mihaip/google-reader-api/blob/master/wiki/ApiStreamItemsIds.wiki
|
|
|
// https://code.google.com/archive/p/pyrfeed/wikis/GoogleReaderAPI.wiki
|
|
// https://code.google.com/archive/p/pyrfeed/wikis/GoogleReaderAPI.wiki
|
|
|
// https://web.archive.org/web/20210126115837/https://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2#feed
|
|
// https://web.archive.org/web/20210126115837/https://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2#feed
|
|
|
|
|
+ header('Content-Type: application/json; charset=UTF-8');
|
|
|
|
|
+
|
|
|
$type = 'A';
|
|
$type = 'A';
|
|
|
if ($streamId === 'user/-/state/com.google/reading-list') {
|
|
if ($streamId === 'user/-/state/com.google/reading-list') {
|
|
|
$type = 'A';
|
|
$type = 'A';
|
|
@@ -838,24 +840,39 @@ TXT;
|
|
|
if (empty($ids) && isset($_GET['client']) && $_GET['client'] === 'newsplus') {
|
|
if (empty($ids) && isset($_GET['client']) && $_GET['client'] === 'newsplus') {
|
|
|
$ids = [ 0 ]; //For News+ bug https://github.com/noinnion/newsplus/issues/84#issuecomment-57834632
|
|
$ids = [ 0 ]; //For News+ bug https://github.com/noinnion/newsplus/issues/84#issuecomment-57834632
|
|
|
}
|
|
}
|
|
|
- $itemRefs = [];
|
|
|
|
|
|
|
+ $nbItems = 0;
|
|
|
|
|
+
|
|
|
|
|
+ // Note: This section must be streamed to avoid memory issues with large responses
|
|
|
|
|
+ echo <<<'TXT'
|
|
|
|
|
+ {
|
|
|
|
|
+ "itemRefs": [
|
|
|
|
|
+
|
|
|
|
|
+ TXT;
|
|
|
foreach ($ids as $entryId) {
|
|
foreach ($ids as $entryId) {
|
|
|
- $itemRefs[] = [
|
|
|
|
|
- 'id' => '' . $entryId, //64-bit decimal
|
|
|
|
|
- ];
|
|
|
|
|
|
|
+ if ($nbItems > 0) {
|
|
|
|
|
+ echo ",\n";
|
|
|
|
|
+ }
|
|
|
|
|
+ echo json_encode(['id' => '' . $entryId], JSON_OPTIONS); //64-bit decimal
|
|
|
|
|
+ $nbItems++;
|
|
|
}
|
|
}
|
|
|
|
|
+ echo <<<'TXT'
|
|
|
|
|
|
|
|
- $response = [
|
|
|
|
|
- 'itemRefs' => $itemRefs,
|
|
|
|
|
- ];
|
|
|
|
|
|
|
+ ]
|
|
|
|
|
+ TXT;
|
|
|
if (count($ids) >= $count) {
|
|
if (count($ids) >= $count) {
|
|
|
$entryId = end($ids);
|
|
$entryId = end($ids);
|
|
|
if ($entryId != false) {
|
|
if ($entryId != false) {
|
|
|
- $response['continuation'] = '' . $entryId;
|
|
|
|
|
|
|
+ echo <<<TXT
|
|
|
|
|
+ ,
|
|
|
|
|
+ "continuation": "$entryId"
|
|
|
|
|
+ TXT;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ echo <<<'TXT'
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- echo json_encode($response, JSON_OPTIONS), "\n";
|
|
|
|
|
|
|
+ TXT;
|
|
|
exit();
|
|
exit();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -882,12 +899,12 @@ TXT;
|
|
|
|
|
|
|
|
// Note: This section must be streamed to avoid memory issues with large responses
|
|
// Note: This section must be streamed to avoid memory issues with large responses
|
|
|
echo <<<TXT
|
|
echo <<<TXT
|
|
|
-{
|
|
|
|
|
- "id": "user/-/state/com.google/reading-list",
|
|
|
|
|
- "updated": $time,
|
|
|
|
|
- "items": [
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ "id": "user/-/state/com.google/reading-list",
|
|
|
|
|
+ "updated": $time,
|
|
|
|
|
+ "items": [
|
|
|
|
|
|
|
|
-TXT;
|
|
|
|
|
|
|
+ TXT;
|
|
|
foreach ($items as $item) {
|
|
foreach ($items as $item) {
|
|
|
if (!is_array($item) || empty($item)) {
|
|
if (!is_array($item) || empty($item)) {
|
|
|
continue;
|
|
continue;
|
|
@@ -901,10 +918,10 @@ TXT;
|
|
|
}
|
|
}
|
|
|
echo <<<'TXT'
|
|
echo <<<'TXT'
|
|
|
|
|
|
|
|
- ]
|
|
|
|
|
-}
|
|
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
-TXT;
|
|
|
|
|
|
|
+ TXT;
|
|
|
exit();
|
|
exit();
|
|
|
}
|
|
}
|
|
|
|
|
|