aboutsummaryrefslogtreecommitdiff
path: root/p/api/greader.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2017-10-01 18:31:28 +0200
committerGravatar GitHub <noreply@github.com> 2017-10-01 18:31:28 +0200
commitceda55c75b158fc1cf4813fe0f258527754b9289 (patch)
tree7c84ac32cc845ab1d70ea5a3fb263c6613de34b0 /p/api/greader.php
parentcb7ba3e47576aa1d0c3f53e5966f831e6540bbc3 (diff)
parentf241fc1841df89285ecb6f124f0d70198d712b2f (diff)
Merge pull request #1651 from FreshRSS/dev1.8.0
Release 1.8.0
Diffstat (limited to 'p/api/greader.php')
-rw-r--r--p/api/greader.php62
1 files changed, 44 insertions, 18 deletions
diff --git a/p/api/greader.php b/p/api/greader.php
index e1f4202a7..b87fcc225 100644
--- a/p/api/greader.php
+++ b/p/api/greader.php
@@ -2,10 +2,10 @@
/**
== Description ==
Server-side API compatible with Google Reader API layer 2
- for the FreshRSS project http://freshrss.org
+ for the FreshRSS project https://freshrss.org
== Credits ==
-* 2014-03: Released by Alexandre Alapetite http://alexandre.alapetite.fr
+* 2014-03: Released by Alexandre Alapetite https://alexandre.alapetite.fr
under GNU AGPL 3 license http://www.gnu.org/licenses/agpl-3.0.html
== Documentation ==
@@ -23,7 +23,7 @@ Server-side API compatible with Google Reader API layer 2
require('../../constants.php');
require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader
-$ORIGINAL_INPUT = file_get_contents('php://input', false, null, -1, 1048576);
+$ORIGINAL_INPUT = file_get_contents('php://input', false, null, 0, 1048576);
if (PHP_INT_SIZE < 8) { //32-bit
function dec2hex($dec) {
@@ -86,7 +86,7 @@ function debugInfo() {
if (function_exists('getallheaders')) {
$ALL_HEADERS = getallheaders();
} else { //nginx http://php.net/getallheaders#84262
- $ALL_HEADERS = '';
+ $ALL_HEADERS = array();
foreach ($_SERVER as $name => $value) {
if (substr($name, 0, 5) === 'HTTP_') {
$ALL_HEADERS[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
@@ -94,7 +94,16 @@ function debugInfo() {
}
}
global $ORIGINAL_INPUT;
- return print_r(array('date' => date('c'), 'headers' => $ALL_HEADERS, '_SERVER' => $_SERVER, '_GET' => $_GET, '_POST' => $_POST, '_COOKIE' => $_COOKIE, 'INPUT' => $ORIGINAL_INPUT), true);
+ return print_r(
+ array(
+ 'date' => date('c'),
+ 'headers' => $ALL_HEADERS,
+ '_SERVER' => $_SERVER,
+ '_GET' => $_GET,
+ '_POST' => $_POST,
+ '_COOKIE' => $_COOKIE,
+ 'INPUT' => $ORIGINAL_INPUT
+ ), true);
}
function badRequest() {
@@ -503,7 +512,7 @@ function streamContents($path, $include_target, $start_time, $count, $order, $ex
$item = array(
'id' => /*'tag:google.com,2005:reader/item/' .*/ dec2hex($entry->id()), //64-bit hexa http://code.google.com/p/google-reader-api/wiki/ItemId
'crawlTimeMsec' => substr($entry->id(), 0, -3),
- 'timestampUsec' => $entry->id(), //EasyRSS
+ 'timestampUsec' => '' . $entry->id(), //EasyRSS
'published' => $entry->date(true),
'title' => $entry->title(),
'summary' => array('content' => $entry->content()),
@@ -694,8 +703,8 @@ $pathInfo = empty($_SERVER['PATH_INFO']) ? '/Error' : urldecode($_SERVER['PATH_I
$pathInfos = explode('/', $pathInfo);
Minz_Configuration::register('system',
- DATA_PATH . '/config.php',
- FRESHRSS_PATH . '/config.default.php');
+ DATA_PATH . '/config.php',
+ FRESHRSS_PATH . '/config.default.php');
FreshRSS_Context::$system_conf = Minz_Configuration::get('system');
if (!FreshRSS_Context::$system_conf->api_enabled) {
serviceUnavailable();
@@ -715,24 +724,34 @@ Minz_Session::_param('currentUser', $user);
if (count($pathInfos) < 3) {
badRequest();
-}
-elseif ($pathInfos[1] === 'accounts') {
+} elseif ($pathInfos[1] === 'accounts') {
if (($pathInfos[2] === 'ClientLogin') && isset($_REQUEST['Email']) && isset($_REQUEST['Passwd'])) {
clientLogin($_REQUEST['Email'], $_REQUEST['Passwd']);
}
-}
-elseif ($pathInfos[1] === 'reader' && $pathInfos[2] === 'api' && isset($pathInfos[3]) && $pathInfos[3] === '0' && isset($pathInfos[4])) {
+} elseif ($pathInfos[1] === 'reader' && $pathInfos[2] === 'api' && isset($pathInfos[3]) && $pathInfos[3] === '0' && isset($pathInfos[4])) {
if ($user == '') {
unauthorized();
}
$timestamp = isset($_GET['ck']) ? intval($_GET['ck']) : 0; //ck=[unix timestamp] : Use the current Unix time here, helps Google with caching.
switch ($pathInfos[4]) {
case 'stream':
- $exclude_target = isset($_GET['xt']) ? $_GET['xt'] : ''; //xt=[exclude target] : Used to exclude certain items from the feed. For example, using xt=user/-/state/com.google/read will exclude items that the current user has marked as read, or xt=feed/[feedurl] will exclude items from a particular feed (obviously not useful in this request, but xt appears in other listing requests).
+ /* xt=[exclude target] : Used to exclude certain items from the feed.
+ * For example, using xt=user/-/state/com.google/read will exclude items
+ * that the current user has marked as read, or xt=feed/[feedurl] will
+ * exclude items from a particular feed (obviously not useful in this
+ * request, but xt appears in other listing requests). */
+ $exclude_target = isset($_GET['xt']) ? $_GET['xt'] : '';
$count = isset($_GET['n']) ? intval($_GET['n']) : 20; //n=[integer] : The maximum number of results to return.
$order = isset($_GET['r']) ? $_GET['r'] : 'd'; //r=[d|n|o] : Sort order of item results. d or n gives items in descending date order, o in ascending order.
- $start_time = isset($_GET['ot']) ? intval($_GET['ot']) : 0; //ot=[unix timestamp] : The time from which you want to retrieve items. Only items that have been crawled by Google Reader after this time will be returned.
- $continuation = isset($_GET['c']) ? $_GET['c'] : ''; //Continuation token. If a StreamContents response does not represent all items in a timestamp range, it will have a continuation attribute. The same request can be re-issued with the value of that attribute put in this parameter to get more items
+ /* ot=[unix timestamp] : The time from which you want to retrieve
+ * items. Only items that have been crawled by Google Reader after
+ * this time will be returned. */
+ $start_time = isset($_GET['ot']) ? intval($_GET['ot']) : 0;
+ /* Continuation token. If a StreamContents response does not represent
+ * all items in a timestamp range, it will have a continuation attribute.
+ * The same request can be re-issued with the value of that attribute put
+ * in this parameter to get more items */
+ $continuation = isset($_GET['c']) ? $_GET['c'] : '';
if (isset($pathInfos[5]) && $pathInfos[5] === 'contents' && isset($pathInfos[6])) {
if (isset($pathInfos[7])) {
if ($pathInfos[6] === 'feed') {
@@ -757,7 +776,10 @@ elseif ($pathInfos[1] === 'reader' && $pathInfos[2] === 'api' && isset($pathInfo
}
} elseif ($pathInfos[5] === 'items') {
if ($pathInfos[6] === 'ids' && isset($_GET['s'])) {
- $streamId = $_GET['s']; //StreamId for which to fetch the item IDs. The parameter may be repeated to fetch the item IDs from multiple streams at once (more efficient from a backend perspective than multiple requests).
+ /* StreamId for which to fetch the item IDs. The parameter may
+ * be repeated to fetch the item IDs from multiple streams at once
+ * (more efficient from a backend perspective than multiple requests). */
+ $streamId = $_GET['s'];
streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude_target);
}
}
@@ -779,8 +801,12 @@ elseif ($pathInfos[1] === 'reader' && $pathInfos[2] === 'api' && isset($pathInfo
break;
case 'edit':
if (isset($_POST['s']) && isset($_POST['ac'])) {
- $streamNames = multiplePosts('s'); //StreamId to operate on. The parameter may be repeated to edit multiple subscriptions at once
- $titles = multiplePosts('t'); //Title to use for the subscription. For the `subscribe` action, if not specified then the feed's current title will be used. Can be used with the `edit` action to rename a subscription
+ //StreamId to operate on. The parameter may be repeated to edit multiple subscriptions at once
+ $streamNames = multiplePosts('s');
+ /* Title to use for the subscription. For the `subscribe` action,
+ * if not specified then the feed's current title will be used. Can
+ * be used with the `edit` action to rename a subscription */
+ $titles = multiplePosts('t');
$action = $_POST['ac']; //Action to perform on the given StreamId. Possible values are `subscribe`, `unsubscribe` and `edit`
$add = isset($_POST['a']) ? $_POST['a'] : ''; //StreamId to add the subscription to (generally a user label)
$remove = isset($_POST['r']) ? $_POST['r'] : ''; //StreamId to remove the subscription from (generally a user label)