PHP code example of black / yo-php

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

    

black / yo-php example snippets





$yo   = new \Yo\Yo(['token' => 'yourtoken']);
$send = new \Yo\Service\SendYoService($yo->getHttpClient(), $yo->getOptions());
$send->yoAll();




$yo   = new \Yo\Yo(['token' => 'yourtoken']);
$send = new \Yo\Service\SendYoService($yo->getHttpClient(), $yo->getOptions());
$send->yo('USERNAME');




$yo     = new \Yo\Yo(['token' => 'yourtoken']);
$status = new \Yo\Service\StatusService($yo->getHttpClient(), $yo->getOptions());

$subscribers = $status->subscribersCount();




$yo   = new \Yo\Yo(['token' => 'yourtoken', 'link' => 'http://www.desicomments.com/dc/21/50927/50927.gif']);
$send = new \Yo\Service\SendYoService($yo->getHttpClient(), $yo->getOptions());
$send->yoAll();



$yo   = new \Yo\Yo(['token' => 'yourtoken');
$yo->addLink('http://www.desicomments.com/dc/21/50927/50927.gif');

$send = new \Yo\Service\SendYoService($yo->getHttpClient(), $yo->getOptions());
$send->yoAll();


$coordinates = new Geo\Coordinates(latitude, longitude);
$yo->addLocation($coordinates);




namespace Yo\Controller;

class YoController
{
    public function yoAction($username, $location = null)
    {
        $yoUser   = new \Yo\Model\YoUser($username);
        
        if (null !== $location) {
            $location    = explode(";", $location);
            $coordinates = new Geo\Coordinates($location[0], $location[1]);
            $yoUser->addLocation($location);
        }

        $dispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();
        $dispatcher->addSubscriber(new YourSubscriber());

        $yo = new \Yo\Service\ReceiveYoService($dispatcher);
        $yo->receive($yoUser);
    }
}




namespace Yo\Controller;

class YoController
{
    public function yoAction($username)
    {
        $yoUser     = new \Yo\Model\YoUser($username);
        $logger     = new Monolog\Logger();
        $dispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();

        $dispatcher->addSubscriber(new \Yo\Event\YoSubscriber($logger));

        $yo = new \Yo\Service\ReceiveYoService($dispatcher);
        $yo->receive($yoUser);
    }
}
json
{
    "lack/yo-php": "@stable"
    }
}