feedbin

package module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

README

go-feedbin

codecov go report card test status Apache-2.0 license Go.Dev reference Go project version

Feedbin API Documentation: https://github.com/feedbin/feedbin-api.

Install

go get github.com/chyroc/go-feedbin

Usage

Create Page

package main

import (
	"context"
	"fmt"

	"github.com/chyroc/go-feedbin"
)

func main() {
	url := ""
	cli := feedbin.New(feedbin.WithCredential("username", "password"))

	resp, err := cli.CreatePage(context.Background(), &feedbin.CreatePageReq{
		URL: url,
	})
	if err != nil {
		panic(err)
	}
	fmt.Println("title", resp.Title)
	fmt.Println("content", resp.Content)
}

Get Subscriptions

package main

import (
	"context"
	"fmt"

	"github.com/chyroc/go-feedbin"
)

func main() {
	cli := feedbin.New(feedbin.WithCredential("username", "password"))

	resp, err := cli.GetSubscriptions(context.Background(), &feedbin.GetSubscriptionsReq{})
	if err != nil {
		panic(err)
	}
	fmt.Println("subscriptions length:", len(resp.Subscriptions))
	for _, v := range resp.Subscriptions {
		fmt.Println(v.ID, v.Title, v.FeedURL)
	}
}

Extracting Content

package main

import (
	"context"
	"fmt"

	"github.com/chyroc/go-feedbin"
)

func main() {
	url := ""
	cli := feedbin.New()

	resp, err := cli.ExtractingContent(context.Background(), &feedbin.ExtractingContentReq{
		URL: url,
	})
	if err != nil {
		panic(err)
	}
	fmt.Println("title", resp.Title)
	fmt.Println("content", resp.Content)
}

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientOptionFunc

type ClientOptionFunc func(*Feedbin)

func WithCredential

func WithCredential(username, password string) ClientOptionFunc

func WithTimeout added in v0.2.0

func WithTimeout(timeout time.Duration) ClientOptionFunc

type CreatePageReq

type CreatePageReq struct {
	URL   string `json:"url,omitempty"`
	Title string `json:"title,omitempty"` // The title is optional and will only be used if Feedbin cannot find the title of the content.
}

type CreatePageResp

type CreatePageResp struct {
	ID                  int64       `json:"id"`
	FeedID              int         `json:"feed_id"`
	Title               string      `json:"title"`
	Author              interface{} `json:"author"`
	Summary             string      `json:"summary"`
	Content             string      `json:"content"`
	URL                 string      `json:"url"`
	ExtractedContentURL string      `json:"extracted_content_url"`
	Published           time.Time   `json:"published"`
	CreatedAt           time.Time   `json:"created_at"`
}

type ExtractingContentReq

type ExtractingContentReq struct {
	URL string `json:"url,omitempty"`
}

type ExtractingContentResp

type ExtractingContentResp struct {
	Title         string      `json:"title"`
	Author        interface{} `json:"author"`
	DatePublished time.Time   `json:"date_published"`
	Dek           interface{} `json:"dek"`
	LeadImageURL  string      `json:"lead_image_url"`
	Content       string      `json:"content"`
	NextPageURL   interface{} `json:"next_page_url"`
	URL           string      `json:"url"`
	Domain        string      `json:"domain"`
	Excerpt       string      `json:"excerpt"`
	WordCount     int         `json:"word_count"`
	Direction     string      `json:"direction"`
	TotalPages    int         `json:"total_pages"`
	RenderedPages int         `json:"rendered_pages"`
}

type Feedbin

type Feedbin struct {
	// contains filtered or unexported fields
}

func New

func New(options ...ClientOptionFunc) *Feedbin

func (*Feedbin) CreatePage

func (r *Feedbin) CreatePage(ctx context.Context, request *CreatePageReq) (*CreatePageResp, error)

CreatePage can be used to [create a new entry](https://feedbin.com/blog/2019/08/20/save-webpages-to-read-later/) from the URL of an article.

If successful, the response will be the full [entry](https://github.com/feedbin/feedbin-api/blob/master/content/entries.md).

Example
url := ""
cli := feedbin.New(feedbin.WithCredential("username", "password"))

resp, err := cli.CreatePage(context.Background(), &feedbin.CreatePageReq{
	URL: url,
})
if err != nil {
	panic(err)
}
fmt.Println("title", resp.Title)
fmt.Println("content", resp.Content)
Output:

func (*Feedbin) ExtractingContent

func (r *Feedbin) ExtractingContent(ctx context.Context, request *ExtractingContentReq) (*ExtractingContentResp, error)

ExtractingContent uses [Mercury Parser](https://github.com/postlight/mercury-parser) to attempt to extract the full content of a webpage.

The extract service is only available to consumer apps that sync with feedbin.com. It is possible to get a cached article without an account, which is probably why you occasionally get a result.

Example
url := ""
cli := feedbin.New()

resp, err := cli.ExtractingContent(context.Background(), &feedbin.ExtractingContentReq{
	URL: url,
})
if err != nil {
	panic(err)
}
fmt.Println("title", resp.Title)
fmt.Println("content", resp.Content)
Output:

func (*Feedbin) ExtractingContentURL

func (r *Feedbin) ExtractingContentURL(ctx context.Context, request *ExtractingContentReq) string

func (*Feedbin) GetSubscriptions added in v0.3.0

func (r *Feedbin) GetSubscriptions(ctx context.Context, request *GetSubscriptionsReq) (*GetSubscriptionsResp, error)
Example
cli := feedbin.New(feedbin.WithCredential("username", "password"))

resp, err := cli.GetSubscriptions(context.Background(), &feedbin.GetSubscriptionsReq{})
if err != nil {
	panic(err)
}
fmt.Println("subscriptions length:", len(resp.Subscriptions))
for _, v := range resp.Subscriptions {
	fmt.Println(v.ID, v.Title, v.FeedURL)
}
Output:

func (*Feedbin) GetTaggings added in v0.4.0

func (r *Feedbin) GetTaggings(ctx context.Context) (*GetTaggingsResp, error)

type GetSubscriptionsReq added in v0.3.0

type GetSubscriptionsReq struct {
	Since time.Time // since=2013-03-08T09:44:20.449047Z will get all subscriptions created after the iso 8601 timestamp.
	Mode  string    // the only mode available is extended. This includes more metadata for the feed.
}

type GetSubscriptionsResp added in v0.3.0

type GetSubscriptionsResp struct {
	Subscriptions []*Subscription `json:"subscriptions"`
}

type GetTaggingsResp added in v0.4.0

type GetTaggingsResp struct {
	Taggings []*Tagging `json:"taggings"`
}

type Subscription added in v0.3.0

type Subscription struct {
	ID        int         `json:"id"`
	CreatedAt time.Time   `json:"created_at"`
	FeedID    int         `json:"feed_id"`
	Title     string      `json:"title"`
	FeedURL   string      `json:"feed_url"`
	SiteURL   string      `json:"site_url"`
	JSONFeed  interface{} `json:"json_feed"`
}

type Tagging added in v0.4.0

type Tagging struct {
	ID     int    `json:"id"`
	FeedID int    `json:"feed_id"`
	Name   string `json:"name"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL