PHP Classes

File: src/Services/Joke/IcndbApi.php

Recommend this page to a friend!
  Classes of Joseluis Laso   PHP Telegram CLI Wrapper   src/Services/Joke/IcndbApi.php   Download  
File: src/Services/Joke/IcndbApi.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP Telegram CLI Wrapper
Send messages and other commands to Telegram users
Author: By
Last change:
Date: 8 years ago
Size: 468 bytes
 

Contents

Class file image Download
<?php

namespace TelegramCliWrapper\Services\Joke;

class
IcndbApi
{
    const
URL = "http://api.icndb.com/jokes/random?limitTo=[nerdy,explicit]";

    public static function
getAJoke()
    {
       
$result = json_decode(file_get_contents(self::URL), true);

        if (isset(
$result['type']) && ($result['type'] == "success")) {
            return
$result['value']['joke'];
        }

        return
"I'm so sorry. I'm so sad to tell you something funny!";
    }

}