Documentation
¶
Index ¶
- Constants
- func CheckImage(imageURL string) bool
- func ConvertStrEncode(inStr, inCharset, outCharset string) string
- func DB() *gorm.DB
- func GetToken() string
- func PostArticle(article Article) (int64, error)
- func PublishArticle() error
- func SpiderArticle(urlStr string) error
- func UTF8ToGBK(utf8 []byte) (gbk []byte, err error)
- type AiCategories
- type AiCategoryItem
- type AiData
- type AiTag
- type AiTagParam
- type AiTags
- type Article
- func (a Article) AiGetCategories() (tags AiCategories, err error)
- func (a Article) AiGetTags() (tags AiTags, err error)
- func (article *Article) GetArticleByID(id int64)
- func (article *Article) GetArticleByURL(url string)
- func (article *Article) GetArticles() []Article
- func (article *Article) GetPlanPublushArticle() []Article
- func (article *Article) Save()
- type AuthResponse
- type Authorizer
- type BaiDuAiConf
- type Client
- type Config
- type DefaultAuthorizer
- type PostConfig
- type PostMessage
- type WebServe
Constants ¶
View Source
const BAIDU_AUTH_URL = "https://openapi.baidu.com/oauth/2.0/token"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AiCategories ¶
type AiCategories struct {
LogID int64 `json:"log_id"`
Item AiCategoryItem `json:"item"`
ErrorMSG string `json:"error_msg"`
ErrorCode int `json:"error_code"`
}
type AiCategoryItem ¶
type AiTagParam ¶
type Article ¶
type Article struct {
ID uint `gorm:"primary_key"`
Title string // 标题
Author string // 作者
AppName string // 公众号名称
AppID string // 公众号ID
Cover string // 文章封面
Intro string // 描述
Body string // 公众号文章内容(正文)
Cont string // 公众号文章内容(文本)
PubAt string // 发布时间
URL string `gorm:"type:varchar(255);unique_index"` // 微信文章链接地址
RoundHead string // 圆头像
OriHead string // 原头像
SourceURL string // 公众号原文地址
PublishAt int64 `sql:"index" default:"0"` //采集器发布时间
PostID int64 // 发布线上返回的id
Tags string // 标签字符串
Category string // 一级分类
Categories string // 二级分类
Copyright string // 已经 0,1,2 微小宝那 1 标识为原创
Video string // 视频地址
Audio string // 音频地址
WxID string // 微信公众号ID
WxIntro string // 微信公众号介绍
Images string
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `sql:"index"`
}
Article 微信公众号文章
func (Article) AiGetCategories ¶
func (a Article) AiGetCategories() (tags AiCategories, err error)
AiGetCategories 文章通过ai.baidu.com 获取标签
func (*Article) GetArticleByID ¶
GetArticleByID 通过ID获取Article
func (*Article) GetArticleByURL ¶
GetArticleByURL Article 如果没有的话进行初始化
func (*Article) GetArticles ¶
GetArticles 获取最新采集的微信公众号文章列表 []Article
func (*Article) GetPlanPublushArticle ¶
GetPlanPublushArticle 获取计划发布的 []Article
type AuthResponse ¶
type AuthResponse struct {
AccessToken string `json:"access_token"` //要获取的Access Token
ExpireIn string `json:"expire_in"` //Access Token的有效期(秒为单位,一般为1个月);
RefreshToken string `json:"refresh_token"` //以下参数忽略,暂时不用
Scope string `json:"scope"`
SessionKey string `json:"session_key"`
SessionSecret string `json:"session_secret"`
ERROR string `json:"error"` //错误码;关于错误码的详细信息请参考鉴权认证错误码(http://ai.baidu.com/docs#/Auth/top)
ErrorDescription string `json:"error_description"` //错误描述信息,帮助理解和解决发生的错误。
}
type Authorizer ¶
Authorizer 用于设置access_token 可以通过RESTFul api的方式从百度方获取 有效期为一个月,可以存至数据库中然后从数据库中获取
type BaiDuAiConf ¶
BaiDuAiConf 百度ai的密令
type Client ¶
type Client struct {
ClientID string
ClientSecret string
AccessToken string
Authorizer Authorizer
}
func (*Client) SetAuther ¶
func (client *Client) SetAuther(auth Authorizer)
type Config ¶
type Config struct {
BaiDuAiConf BaiDuAiConf
PostConfig PostConfig
WebServe WebServe
}
Config 配置
type DefaultAuthorizer ¶
type DefaultAuthorizer struct{}
func (DefaultAuthorizer) Authorize ¶
func (da DefaultAuthorizer) Authorize(client *Client) error
type PostConfig ¶
type PostConfig struct {
ServeURL string `toml:"serve_url"`
AuthorizationToken string `toml:"authorization_token"`
}
PostConfig 配置
type PostMessage ¶
PostMessage 发布数据返回消息 成功返回 id 失败返回json
Click to show internal directories.
Click to hide internal directories.