1. Go to this page and download the library: Download mekras/atompub library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mekras / atompub example snippets
use Mekras\Atom\Document\EntryDocument;
use Mekras\Atom\Document\FeedDocument;
use Mekras\Atom\Exception\AtomException;
use Mekras\AtomPub\Document\CategoryDocument;
use Mekras\AtomPub\Document\ServiceDocument;
use Mekras\AtomPub\DocumentFactory;
$factory = new DocumentFactory;
$xml = file_get_contents('http://example.com/atom');
try {
$document = $factory->parseXML($xml);
} catch (AtomException $e) {
die($e->getMessage());
}
if ($document instanceof CategoryDocument) {
$categories = $document->getCategories();
//...
} elseif ($document instanceof ServiceDocument) {
$workspaces = $document->getWorkspaces();
//...
} elseif ($document instanceof FeedDocument) {
$feed = $document->getFeed();
//...
} elseif ($document instanceof EntryDocument) {
$entry = $document->getEntry();
//...
}
use Mekras\AtomPub\DocumentFactory;
$factory = new DocumentFactory;
$document = $factory->createDocument('atom:entry');
$entry = $document->getEntry();
$entry->addId('urn:entry:0001');
$entry->addTitle('Entry Title');
$entry->addAuthor('Author 1')->setEmail('[email protected]');
$entry->addContent('<h1>Entry content</h1>', 'html');
$entry->addCategory('tag1')->setLabel('Tag label')->setScheme('http://example.com/scheme');
$entry->addUpdated(new \DateTime());
// Suppose that $httpClient is some kind of HTTP client...
$httpClient->sendRequest('POST', 'http://example.com/', (string) $document);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.