PHP code example of happytodev / blueskyapiwithphp

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

    

happytodev / blueskyapiwithphp example snippets




namespace App\Http\Controllers;

use Happytodev\Blueskyapiwithphp\Blueskyapiwithphp;

class BlueskyController extends Controller
{
    protected $blueskyApi;

    public function __construct()
    {
        $this->blueskyApi = new Blueskyapiwithphp(config('services.bluesky.api_key'));
    }

    public function showLikes($handle, $postId)
    {
        $likes = $this->blueskyApi->getPostLikes($handle, $postId);

        return view('likes', compact('likes'));
    }

    public function showPostLikesNumber($handle, $postId)
    {
        $likesCount = $this->blueskyApi->getPostLikesCount($handle, $postId);
        $repostsCount = $this->blueskyApi->getPostRepostsCount($handle, $postId);
        $repliesCount = $this->blueskyApi->getPostRepliesCount($handle, $postId);

        dd($likesCount, $repostsCount, $repliesCount);
    }
}