orthosie / theysaidso-quotes
There is no license information available for the latest version (v1.0.0) of this package.
A fluent PHP client for world famous They Said So quotes platform.
v1.0.0
2024-08-15 16:57 UTC
Requires
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
README
A fluent php client library for They Said So quotes API. You can get the API key here. [https://theysaidso.com/api]
Installation
composer require orthosie/theysaidso-quotes
Get Quote of the day
use TheySaidSo\QuoteOfTheDay;
$qod = QuoteOfTheDay::withCredential('<apikey>')->category('inspire')->get();
print "Quote of the day\n";
print $qod[0]['quote'] ." - " . $qod[0]['author'] . "\n";
Get Random Quote
Get a random quote
use TheySaidSo\Quotes;
$quotes = Quotes::withCredential(<api-key>)->random()->limit(1)->get();
print "A quote by " . $quotes[0]['author'] . "\n";
print $quotes[0]['quote'] ."\n";
Search Quotes
Search for a quote from Steve Jobs that says something about design
use TheySaidSo\Quotes;
$quotes = Quotes::withCredential(<api-key>)->search('design')->author('Steve Jobs')->get();
print "A quote by " . $quotes[0]['author'] . " on design\n";
print $quotes[0]['quote'] ."\n";
Full Options on search
Here are the full options on search API.
use TheySaidSo\Quotes;
$quotes = Quotes::withCredential(<api-key>)
->search('design')
->author('Steve Jobs')
->category('experience') // quote should have a tag 'experience'
->minLength(10) // quote length should be > 10 characters
->maxLength(512) // quote length should be < 512 characters
->sfw(true) // Search only Safe for work quotes
->private(false) // Search public quotes not quotes added by you
->get();
print "A quote by " . $quotes[0]['author'] . " on design\n";
print $quotes[0]['quote'] ."\n";
Rate Limit Numbers
After you make a call to the server you can get the rate limit numbers from the client library.
use TheySaidSo\Quotes;
$theysaidso = Quotes::withCredential(<api-key>);
$quotes = $theysaidso->random()->limit(1)->get();
print "Total limit for this period " . $theysaidso->totalLimit() . "\n";
print "Limit remaining " . $theysaidso->limitRemaining() . "\n";