PHP code example of michaeljamesparsons / metropublisher-php-sdk

1. Go to this page and download the library: Download michaeljamesparsons/metropublisher-php-sdk 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/ */

    

michaeljamesparsons / metropublisher-php-sdk example snippets



use MetroPublisher\MetroPublisher;
use MetroPublisher\Api\Models\Article;

//Create a new MetroPublisher API instance
$metroPublisher = new MetroPublisher("{public key}", "{secret key}");

//Create a new article
$article = new Article($metroPublisher);
$article->setUuid('41b47ff8-3355-4f69-a867-7232165e6d29')
    ->setUrlname('lorem-ipsum')
    ->setTitle('Lorem Ipsum')
    ->setMetaTitle('Lorem Ipsum')
    ->setDescription('Lorem ipsum dolor sit amet, consectetur adipiscing elit.')
    ->setMetaDescription('Lorem ipsum dolor sit amet, consectetur adipiscing elit.')
    ->setPrintDescription('Lorem ipsum dolor sit amet, consectetur adipiscing elit.')
    ->setContent('<p>Quisque sed erat sed ex eleifend sollicitudin eu id ligula.</p>')
    ->setFeatureImageUuid(null)
    ->setTeaserImageUuid(null)
    ->setIssued(new DateTime('now'))
    ->setEvergreen(true);

//Save the article
$article->save();

//Delete the article
$article->delete();


use MetroPublisher\Api\Collections\ArticleCollection;

$articleCollection = new ArticleCollection($metroPublisher);

//Get group of articles
$articles = $articleCollection->findAll();
    
//Get next group of articles
$moreArticles = $articleCollection->findAll(2);

//Get a single article
$singleArticle = $articleCollection->find('e6ebac9c-94cb-11e6-ae22-56b6b6499611');