https://github.com/indieweb/representative-h-card-php
Given a parsed mf2 document, return the representative h-card for the page
https://github.com/indieweb/representative-h-card-php
Last synced: about 1 year ago
JSON representation
Given a parsed mf2 document, return the representative h-card for the page
- Host: GitHub
- URL: https://github.com/indieweb/representative-h-card-php
- Owner: indieweb
- License: other
- Created: 2015-12-23T16:22:42.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2023-05-24T15:35:31.000Z (about 3 years ago)
- Last Synced: 2024-10-29T19:00:32.026Z (over 1 year ago)
- Language: PHP
- Homepage: http://microformats.org/wiki/representative-h-card-parsing
- Size: 23.4 KB
- Stars: 15
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
Representative H-Card Parsing
=============================
[](http://travis-ci.org/indieweb/representative-h-card-php)
[](https://packagist.org/packages/indieweb/representative-h-card)
Given a parsed mf2 document, return the [representative h-card](http://microformats.org/wiki/representative-h-card-parsing) for the page.
Installation
------------
Install via composer:
```json
{
"indieweb/representative-h-card": "0.1.*"
}
```
Or just require the one file:
```php
require_once('src/mf2/representative-h-card.php');
```
Usage
-----
This function accepts a PHP array in the format returned by the [microformats2 parser](https://github.com/indieweb/php-mf2).
```php
$url = 'http://aaronparecki.com/';
$html = file_get_contents($url);
$parsed = Mf2\parse($html, $url);
$representative = Mf2\HCard\representative($parsed, $url);
print_r($representative);
```
The function will find the representative h-card (according to the [representative h-card parsing](http://microformats.org/wiki/representative-h-card-parsing) rules) and will
return the h-card that is found.
```
Array
(
[type] => Array
(
[0] => h-card
)
[properties] => Array
(
[name] => Array
(
[0] => Aaron Parecki
)
[photo] => Array
(
[0] => http://aaronparecki.com/images/aaronpk.png
)
[url] => Array
(
[0] => http://aaronparecki.com/
)
[uid] => Array
(
[0] => http://aaronparecki.com/
)
)
)
```