PHP code example of gourmet / social-meta

1. Go to this page and download the library: Download gourmet/social-meta 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/ */

    

gourmet / social-meta example snippets


\Cake\Core\Plugin::load('Gourmet/SocialMeta');

public function initialize(array $config)
{
    $this->loadHelper('Gourmet/SocialMeta.Card');
    $this->loadHelper('Gourmet/SocialMeta.OpenGraph');
}

public function initialize(array $config)
{
    $this->loadHelper('Gourmet/SocialMeta.Card', [
        'card' => 'photo',
        'tags' => ['twitter' => [
            'description' => 'Some default description'
        ]]
    ]);
    $this->loadHelper('Gourmet/SocialMeta.OpenGraph', [
        'app_id' => 'xxx'
    ]);
}

echo $this->OpenGraph->html();

echo $this->OpenGraph->html(['lang' => 'en'], ['foo' => 'http://foo']);

echo $this->OpenGraph->render();

echo $this->OpenGraph
    ->setTitle('My Page')
    ->setDescription('One of my awesome pages')
    ->setImage('http://link.to/image', ['width' => '200', 'height' => '300'])
    ->render();

echo $this->Card
    ->setTitle('My Page')
    ->setDescription('One of my awesome pages')
    ->setImage('http://link.to/image', ['width' => '200', 'height' => '300'])
    ->render();