suomato / hubspot-rss-parser
解析HubSpot rss-feeds并将其转换为PHP对象数组
v1.0.0
2018-07-14 18:15 UTC
Requires
- php: ^7.0
Requires (Dev)
- phpunit/phpunit: ^7
This package is auto-updated.
Last update: 2024-09-29 05:15:00 UTC
README
此库用于将HubSpot rss-feeds解析为PHP对象。
安装
composer require suomato/hubspot-rss-parser
示例
// HubSpot blog RSS feed URL
$rss_feed = 'path/to/rss.xml'
$parser = new Suomato\HubspotParser($rss_feed);
// Array of HubspotPost objects
$posts = $parser->get();
// The First Post Title
$posts[0]->title;
// The First Post link
$posts[0]->link;
// The First Post Image Source
$posts[0]->image['src'];
// The First Post Image alt text
$posts[0]->image['alt'];
// Array of Categories of the First Post
$posts[0]->categories;
过滤帖子
包含
// Only get posts with categories 'foo' OR 'bar'
$posts = $parser->get([
'include' => ['foo', 'bar']
]);
排除
// Only get posts without categories 'foo' OR 'bar'
$posts = $parser->get([
'exclude' => ['foo', 'bar']
]);
限制
// Only get first three posts
$posts = $parser->get([
'limit' => 3
]);
偏移量
// Skips first three posts
$posts = $parser->get([
'offset' => 3
]);