Browse Source

Added profile, tags and resource id helper endpoints

master
boB Rudis 5 years ago
parent
commit
052e0c3c55
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 4
      NAMESPACE
  2. 2
      R/feedly-collections.R
  3. 5
      R/feedly-feed-meta.R
  4. 30
      R/feedly-global-resource-ids.R
  5. 5
      R/feedly-opml.R
  6. 24
      R/feedly-profile.R
  7. 43
      R/feedly-search-contents.R
  8. 16
      R/feedly-search-title.R
  9. 8
      R/feedly-stream.R
  10. 28
      R/feedly-tags.R
  11. 12
      README.Rmd
  12. 58
      README.md
  13. BIN
      README_cache/gfm/unnamed-chunk-4_61b79ac676e0a7ffca44623f1a3ee519.RData
  14. BIN
      README_cache/gfm/unnamed-chunk-4_61b79ac676e0a7ffca44623f1a3ee519.rdb
  15. BIN
      README_cache/gfm/unnamed-chunk-4_61b79ac676e0a7ffca44623f1a3ee519.rdx
  16. BIN
      README_cache/gfm/unnamed-chunk-4_a700cde0c14bf33792b5f47e1837ff07.RData
  17. BIN
      README_cache/gfm/unnamed-chunk-4_a700cde0c14bf33792b5f47e1837ff07.rdb
  18. BIN
      README_cache/gfm/unnamed-chunk-4_a700cde0c14bf33792b5f47e1837ff07.rdx
  19. 4
      man/feedly_feed_meta.Rd
  20. 5
      man/feedly_opml.Rd
  21. 17
      man/feedly_profile.Rd
  22. 12
      man/feedly_search_title.Rd
  23. 21
      man/feedly_tags.Rd
  24. 36
      man/global_resource_ids.Rd

4
NAMESPACE

@ -5,8 +5,10 @@ export(feedly_access_token)
export(feedly_connections)
export(feedly_feed_meta)
export(feedly_opml)
export(feedly_search)
export(feedly_profile)
export(feedly_search_title)
export(feedly_stream)
export(feedly_tags)
import(httr)
importFrom(jsonlite,fromJSON)
importFrom(magrittr,"%>%")

2
R/feedly-collections.R

@ -12,7 +12,7 @@ feedly_connections <- function(with_stats=FALSE,
httr::GET(
url = "https://cloud.feedly.com/v3/collections",
httr::add_headers(
`Authorization` = sprintf("OAuth %s", feedly_access_token())
`Authorization` = sprintf("OAuth %s", feedly_token)
),
query = list(
withStats = if (with_stats) "true" else "false"

5
R/feedly-feed-meta.R

@ -3,6 +3,7 @@
#' @md
#' @note This endpoint will do a real-time fetch of the feed if the submitted feed is not yet part of the feedly cloud.
#' @param feed an RSS feed URL. `feed/` will be prepended if not present.
#' @param feedly_token Your Feedly Developer Access Token (see [feedly_access_token()])
#' @references (<https://developer.feedly.com/v3/feeds/>)
#' @return data frame (tibble) with the following fields:
#' - `id`:
@ -28,14 +29,14 @@
#' @export
#' @examples
#' feedly_feed_meta("https://feeds.feedburner.com/rweeklylive")
feedly_feed_meta <- function(feed) {
feedly_feed_meta <- function(feed, feedly_token = feedly_access_token()) {
feed <- curl::curl_escape(sprintf("feed/%s", sub("^feed/", "", feed)))
httr::GET(
url = sprintf("https://cloud.feedly.com/v3/feeds/%s", feed),
httr::add_headers(
`Authorization` = sprintf("OAuth %s", feedly_access_token())
`Authorization` = sprintf("OAuth %s", feedly_token)
)
) -> res

30
R/feedly-global-resource-ids.R

@ -0,0 +1,30 @@
#' Global Resource Ids
#'
#' @name global_resource_ids
#' @rdname global_resource_ids
#' @description The following is a list of built-in categories and tags applications can take advantage of. These ids are not returned by the APIs directly, they must be constructed in code.
#' @references (<https://developer.feedly.com/cloud/>)
#' @md
#' @section Id List:
#'
#' - `user/:userId/category/global.all`
#' All articles from all the feeds the user subscribes to (example: `user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/category/global.all`)
#' - `user/:userId/category/global.uncategorized`
#' All the articles from all the sources the user subscribes to and are not in a category (example: `user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/category/global.uncategorized`)
#' - `user/:userId/category/global.must`
#' Users can promote sources they really love to read to must have (example: `user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/category/global.must`)
#' - `user/:userId/tag/global.read’
#' List of entries the user has recently read - limited to the feeds the users subscribes to (example: `user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/tag/global.read`)
#' - `user/:userId/tag/global.saved`
#' Users can save articles for later. Equivalent of starring articles in Google Reader (example: `user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/tag/global.saved`)
#' - `user/:userId/tag/global.all`
#' All articles from all personal tags, including global.saved (example: `user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/tag/global.all`)
#' - `enterprise/:enterpriseName/category/global.all`
#' All articles from all team feeds (example: `enterprise/acmeinc/category/global.all`)
#' - `enterprise/:enterpriseName/tags/global.all`
#' All articles from all team tags (example: `enterprise/acmeinc/tags/global.all`)
#' - `user/:userId/category/global.enterprise`
#' All articles from all the team categories a user is following (example: `user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/category/global.enterprise`)
#' - `user/:userId/tag/global.enterprise`
#' All articles from all the team tags a user is subscribed to (example: `user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/tag/global.enterprise`)
NULL

5
R/feedly-opml.R

@ -8,17 +8,18 @@
#' @md
#' @param as one of "`text`" (plain character XML) or "`parsed`" (which will return
#' an `xml2::xml_document`)
#' @param feedly_token Your Feedly Developer Access Token (see [feedly_access_token()])
#' @references (<https://developer.feedly.com/v3/opml/>)
#' @export
#' @return character or `xml_document` depending on `as`
feedly_opml <- function(as = c("text", "parsed")) {
feedly_opml <- function(as = c("text", "parsed"), feedly_token = feedly_access_token()) {
as <- match.arg(as[1], c("text", "parsed"))
httr::GET(
url = "https://cloud.feedly.com/v3/opml",
httr::add_headers(
`Authorization` = sprintf("OAuth %s", feedly_access_token())
`Authorization` = sprintf("OAuth %s", feedly_token)
)
) -> res

24
R/feedly-profile.R

@ -0,0 +1,24 @@
#' Retrieve Your Feedly Profile
#'
#' @md
#' @param feedly_token Your Feedly Developer Access Token (see [feedly_access_token()])
#' @references (<https://developer.feedly.com/v3/opml/>)
#' @export
feedly_profile <- function(feedly_token = feedly_access_token()) {
httr::GET(
url = "https://cloud.feedly.com/v3/profile",
httr::add_headers(
`Authorization` = sprintf("OAuth %s", feedly_token)
)
) -> res
httr::stop_for_status(res)
out <- httr::content(res, as="text")
out <- jsonlite::fromJSON(out)
out
}

43
R/feedly-search-contents.R

@ -0,0 +1,43 @@
# Find feeds based on contents
#
# @md
# @param query a full or partial title string, URL, or `#topic`
# @param count number of items to return (API default is 20)
# @param locale if not `NULL` then a Feedly-recognized locale string (see
# `References`) to provide a hint to the search engine to return feeds
# in that locale.
# @param feedly_token Your Feedly Developer Access Token (see [feedly_access_token()])
# @references (<https://developer.feedly.com/v3/search/>) & [Search Tutorial](https://feedly.uservoice.com/knowledgebase/articles/441699-power-search-tutorial)
# @seealso feedly_search_title
# @return list similar to [feedly_stream()]
# @examples
# feedly_search_title("data science")
# feedly_search_contents <- function(query, count=20L, locale=NULL, feedly_token = feedly_access_token()) {
#
# ct <- as.integer(count)
#
# query <- query[1]
#
# httr::GET(
# url = "https://cloud.feedly.com/v3/search/feeds",
# if (!is.null(feedly_token)) {
# httr::add_headers(
# `Authorization` = sprintf("OAuth %s", feedly_token)
# )
# },
# query = list(
# query = query,
# count = ct,
# locale = locale
# )
# ) -> res
#
# httr::stop_for_status(res)
#
# out <- httr::content(res, as="text")
#
# out <- jsonlite::fromJSON(out)
#
# out
#
# }

16
R/feedly-search.R → R/feedly-search-title.R

@ -10,12 +10,12 @@
#' `References`) to provide a hint to the search engine to return feeds
#' in that locale.
#' @param feedly_token Your Feedly Developer Access Token (see [feedly_access_token()])
#' @references (<https://developer.feedly.com/v3/search/>)
#' @references (<https://developer.feedly.com/v3/search/>) & [Search Tutorial](https://feedly.uservoice.com/knowledgebase/articles/441699-power-search-tutorial)
#' @return list similar to [feedly_stream()]
#' @export
#' @examples
#' feedly_search("data science")
feedly_search <- function(query, count=20L, locale=NULL, feedly_token = feedly_access_token()) {
#' feedly_search_title("data science")
feedly_search_title <- function(query, count=20L, locale=NULL, feedly_token = feedly_access_token()) {
ct <- as.integer(count)
@ -23,9 +23,11 @@ feedly_search <- function(query, count=20L, locale=NULL, feedly_token = feedly_a
httr::GET(
url = "https://cloud.feedly.com/v3/search/feeds",
httr::add_headers(
if (!is.null( feedly_token))`Authorization` = sprintf("OAuth %s", feedly_access_token())
),
if (!is.null(feedly_token)) {
httr::add_headers(
`Authorization` = sprintf("OAuth %s", feedly_token)
)
},
query = list(
query = query,
count = ct,
@ -42,3 +44,5 @@ feedly_search <- function(query, count=20L, locale=NULL, feedly_token = feedly_a
out
}
# @seealso feedly_search_contents

8
R/feedly-stream.R

@ -107,9 +107,11 @@ feedly_stream <- function(stream_id,
httr::GET(
url = "https://cloud.feedly.com/v3/streams/contents",
httr::add_headers(
if (!is.null( feedly_token))`Authorization` = sprintf("OAuth %s", feedly_access_token())
),
if (!is.null(feedly_token)) {
httr::add_headers(
`Authorization` = sprintf("OAuth %s", feedly_token)
)
},
query = list(
streamId = stream_id,
ranked = ranked,

28
R/feedly-tags.R

@ -0,0 +1,28 @@
#' Retrieve List of Tags
#'
#' This endpoint is useful for retrieving ids of Feedly Boards which would
#' then enable you to, say, make your own newsletters without upgrading to Teams.
#'
#' @md
#' @param feedly_token Your Feedly Developer Access Token (see [feedly_access_token()])
#' @references (<https://developer.feedly.com/v3/tags/>)
#' @export
#' @return character or `xml_document` depending on `as`
feedly_tags <- function(feedly_token = feedly_access_token()) {
httr::GET(
url = "https://cloud.feedly.com/v3/tags",
httr::add_headers(
`Authorization` = sprintf("OAuth %s", feedly_token)
)
) -> res
httr::stop_for_status(res)
out <- httr::content(res, as="text")
out <- jsonlite::fromJSON(out)
out
}

12
README.Rmd

@ -20,8 +20,14 @@ The following functions are implemented:
- `feedly_connections`: Retrieve Feedly Connections
- `feedly_feed_meta`: Retrieve Metadata for a Feed
- `feedly_opml`: Retrieve Your Feedly OPML File
- `feedly_search`: Find feeds based on title, url or '#topic'
- `feedly_profile`: Retrieve Your Feedly Profile
- `feedly_search_title`: Find feeds based on title, url or '#topic'
- `feedly_stream`: Retrieve contents of a Feedly "stream"
- `feedly_tags`: Retrieve List of Tags
The following helper references are available:
- `global_resource_ids`: Global Resource Ids Helper Reference
## Authentication (README)
@ -29,7 +35,7 @@ You need a developer token to access most of the API endpoints. You can do that
### NOT ALL ENDPOINTS REQUIRE AUTHENTICATION
Neither `feedly_search()` nor `feedly_stream()` require authentication (i.e. you do not need a developer token) to retrieve the contents of the API call. For `feedly_stream()` You _do_ need to know the Feedly-structured feed id which is (generally) `feed/FEED_URL` (e.g. `feed/http://feeds.feedburner.com/RBloggers`).
Neither `feedly_search_title()` nor `feedly_stream()` require authentication (i.e. you do not need a developer token) to retrieve the contents of the API call. For `feedly_stream()` You _do_ need to know the Feedly-structured feed id which is (generally) `feed/FEED_URL` (e.g. `feed/http://feeds.feedburner.com/RBloggers`).
## Installation
@ -71,7 +77,7 @@ feedly_feed_meta("https://feeds.feedburner.com/rweeklylive") %>%
feedly_opml()
rst <- feedly_search("data science")
rst <- feedly_search_title("data science")
glimpse(rst$results)
```

58
README.md

File diff suppressed because one or more lines are too long

BIN
README_cache/gfm/unnamed-chunk-4_61b79ac676e0a7ffca44623f1a3ee519.RData

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-4_61b79ac676e0a7ffca44623f1a3ee519.rdb

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-4_61b79ac676e0a7ffca44623f1a3ee519.rdx

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-4_a700cde0c14bf33792b5f47e1837ff07.RData

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-4_a700cde0c14bf33792b5f47e1837ff07.rdb

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-4_a700cde0c14bf33792b5f47e1837ff07.rdx

Binary file not shown.

4
man/feedly_feed_meta.Rd

@ -4,10 +4,12 @@
\alias{feedly_feed_meta}
\title{Retrieve Metadata for a Feed}
\usage{
feedly_feed_meta(feed)
feedly_feed_meta(feed, feedly_token = feedly_access_token())
}
\arguments{
\item{feed}{an RSS feed URL. \code{feed/} will be prepended if not present.}
\item{feedly_token}{Your Feedly Developer Access Token (see \code{\link[=feedly_access_token]{feedly_access_token()}})}
}
\value{
data frame (tibble) with the following fields:

5
man/feedly_opml.Rd

@ -4,11 +4,14 @@
\alias{feedly_opml}
\title{Retrieve Your Feedly OPML File}
\usage{
feedly_opml(as = c("text", "parsed"))
feedly_opml(as = c("text", "parsed"),
feedly_token = feedly_access_token())
}
\arguments{
\item{as}{one of "\code{text}" (plain character XML) or "\code{parsed}" (which will return
an \code{xml2::xml_document})}
\item{feedly_token}{Your Feedly Developer Access Token (see \code{\link[=feedly_access_token]{feedly_access_token()}})}
}
\value{
character or \code{xml_document} depending on \code{as}

17
man/feedly_profile.Rd

@ -0,0 +1,17 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/feedly-profile.R
\name{feedly_profile}
\alias{feedly_profile}
\title{Retrieve Your Feedly Profile}
\usage{
feedly_profile(feedly_token = feedly_access_token())
}
\arguments{
\item{feedly_token}{Your Feedly Developer Access Token (see \code{\link[=feedly_access_token]{feedly_access_token()}})}
}
\description{
Retrieve Your Feedly Profile
}
\references{
(\url{https://developer.feedly.com/v3/opml/})
}

12
man/feedly_search.Rd → man/feedly_search_title.Rd

@ -1,10 +1,10 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/feedly-search.R
\name{feedly_search}
\alias{feedly_search}
% Please edit documentation in R/feedly-search-title.R
\name{feedly_search_title}
\alias{feedly_search_title}
\title{Find feeds based on title, url or \code{#topic}}
\usage{
feedly_search(query, count = 20L, locale = NULL,
feedly_search_title(query, count = 20L, locale = NULL,
feedly_token = feedly_access_token())
}
\arguments{
@ -26,8 +26,8 @@ Authorization is \emph{optional} for this API call. Pass in \code{NULL} to \code
to make unauthenticated calls to this API endpoint.
}
\examples{
feedly_search("data science")
feedly_search_title("data science")
}
\references{
(\url{https://developer.feedly.com/v3/search/})
(\url{https://developer.feedly.com/v3/search/}) & \href{https://feedly.uservoice.com/knowledgebase/articles/441699-power-search-tutorial}{Search Tutorial}
}

21
man/feedly_tags.Rd

@ -0,0 +1,21 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/feedly-tags.R
\name{feedly_tags}
\alias{feedly_tags}
\title{Retrieve List of Tags}
\usage{
feedly_tags(feedly_token = feedly_access_token())
}
\arguments{
\item{feedly_token}{Your Feedly Developer Access Token (see \code{\link[=feedly_access_token]{feedly_access_token()}})}
}
\value{
character or \code{xml_document} depending on \code{as}
}
\description{
This endpoint is useful for retrieving ids of Feedly Boards which would
then enable you to, say, make your own newsletters without upgrading to Teams.
}
\references{
(\url{https://developer.feedly.com/v3/tags/})
}

36
man/global_resource_ids.Rd

@ -0,0 +1,36 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/feedly-global-resource-ids.R
\name{global_resource_ids}
\alias{global_resource_ids}
\title{Global Resource Ids}
\description{
The following is a list of built-in categories and tags applications can take advantage of. These ids are not returned by the APIs directly, they must be constructed in code.
}
\section{Id List}{
\itemize{
\item \code{user/:userId/category/global.all}
All articles from all the feeds the user subscribes to (example: \code{user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/category/global.all})
\item \code{user/:userId/category/global.uncategorized}
All the articles from all the sources the user subscribes to and are not in a category (example: \code{user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/category/global.uncategorized})
\item \code{user/:userId/category/global.must}
Users can promote sources they really love to read to must have (example: \code{user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/category/global.must})
\item \code{user/:userId/tag/global.read’ List of entries the user has recently read - limited to the feeds the users subscribes to (example: }user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/tag/global.read`)
\item \code{user/:userId/tag/global.saved}
Users can save articles for later. Equivalent of starring articles in Google Reader (example: \code{user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/tag/global.saved})
\item \code{user/:userId/tag/global.all}
All articles from all personal tags, including global.saved (example: \code{user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/tag/global.all})
\item \code{enterprise/:enterpriseName/category/global.all}
All articles from all team feeds (example: \code{enterprise/acmeinc/category/global.all})
\item \code{enterprise/:enterpriseName/tags/global.all}
All articles from all team tags (example: \code{enterprise/acmeinc/tags/global.all})
\item \code{user/:userId/category/global.enterprise}
All articles from all the team categories a user is following (example: \code{user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/category/global.enterprise})
\item \code{user/:userId/tag/global.enterprise}
All articles from all the team tags a user is subscribed to (example: \code{user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/tag/global.enterprise})
}
}
\references{
(\url{https://developer.feedly.com/cloud/})
}
Loading…
Cancel
Save