Browsed by
Archives: Code Snippets

new og tags

new og tags

<meta property="fb:app_id" content="XXXXXXXX" /> <meta property="og:locale" content="en_US" /> <meta property="og:type" content="article" /> <meta property="og:title" content="John’s site is better" /> <meta property="og:description" content="John’s site is the best" /> <meta property="og:url" content="https://softsmart.co.za/slugged" /> <meta property="og:site_name" content="SoftSmart" /> <meta property="og:image" content="https://softsmart.co.za/wp-content/uploads/2015/05/my-image.jpg" /> <meta property="og:image:width" content="720" /> <meta property="og:image:height" content="720" />

Og snippet

Og snippet

<meta property="fb:app_id" content="XXXXXXXX" /> <meta property="og:locale" content="en_US" /> <meta property="og:type" content="article" /> <meta property="og:title" content="John’s site is better" /> <meta property="og:description" content="My site is the best" /> <meta property="og:url" content="https://softsmart.co.za/slugged" /> <meta property="og:site_name" content="SoftSmart" /> <meta property="og:image" content="https://softsmart.co.za/wp-content/uploads/2015/05/my-image.jpg" /> <script type="text/javascript"> jQuery( function( $ ) { $.post( ‘https://graph.facebook.com’, { id: ‘https://softsmart.co.za/wp-content/uploads/2015/05/my-image.jpg’, scrape: true }, function(response){ console.log(response); } ); }); </script>

Web CP Installation

Web CP Installation

cd /tmp && wget https://api.webcp.io/downloads/2.0.0/setup/installer.sh && chmod 755 installer.sh && ./installer.sh && rm -fr /tmp/installer.sh

composer autoload

composer autoload

<?php require "vendor/autoload.php"; use \jsmcm\Logger\Log; use \manfred\Reader\Read; $oLog = new Log(); $oRead = new Read();

composer.json

composer.json

{ "autoload": { "psr-4": { "jsmcm\\":"src/jsmcm", "manfred\\":"src/manfred" } } }

spl_autoload_register

spl_autoload_register

<?php use \jsmcm\Logger\Log; use \manfred\Reader\Read; spl_autoload_register(function($class){ $baseDirectory = __DIR__.’/src/’; $classPath = str_replace("\\", "/", $class).".php"; if (file_exists($baseDirectory.$classPath)) { require $baseDirectory.$classPath; } }); $oLog = new Log(); $oRead = new Read();

Require Class

Require Class

<?php require __DIR__."/src/jsmcm/Logger/Log.php"; require __DIR__."/src/manfred/Reader/Read.php"; use \jsmcm\Logger\Log; use \manfred\Reader\Read; $oLog = new Log(); $oRead = new Read();

composer example

composer example

<?php include __DIR__."/vendor/autoload.php"; use Monolog\Logger; use Monolog\Handler\StreamHandler; // create a log channel $log = new Logger(‘usdToZar’); $log->pushHandler(new StreamHandler(‘/var/www/html/test/log’, Logger::DEBUG)); // add records to the log $log->info("About to get exchange rate"); $client = new \GuzzleHttp\Client(); try { $res = $client->request(‘GET’, ‘http://api.softsmart.co.za/exchange/’); } catch (Exception $e) { print "An error occurred and has been logged. Please check the log file for info!"; $log->error("http request error resulted in an error", array("error"=>$e)); exit(); } $log->info("http result: ".$res->getStatusCode()); if ($res->getStatusCode() != 200) { $log->error("http request…

Read More Read More

zar-usd

zar-usd

{"from":"usd","to":"zar","rate":13.436604}

Composer Install

Composer Install

composer require monolog/monolog ./composer.json has been created Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 2 installs, 0 updates, 0 removals – Installing psr/log (1.0.2): Loading from cache – Installing monolog/monolog (1.23.0): Loading from cache monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB) monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server) monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required)) monolog/monolog suggests…

Read More Read More