PHP code example of arnaudleroy-studio / dropthe

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

    

arnaudleroy-studio / dropthe example snippets


use DropThe\Client;

$client = new Client();

// List all verticals the platform covers
$verticals = $client->getVerticals();
// ['movies', 'series', 'cryptocurrencies', 'companies', 'people']

// Check coverage stats per vertical
$stats = $client->getStats(vertical: 'movies');
echo "{$stats['vertical']} — {$stats['count']} entities tracked";

// Type-safe search with named arguments
$results = $client->search(
    query: 'Nolan',
    vertical: 'people',
    limit: 5,
);

// Array destructuring from results
foreach ($results as ['name' => $name, 'slug' => $slug, 'type' => $type]) {
    echo "{$name} ({$type}) — dropthe.org/{$slug}\n";
}

$entity = $client->findBySlug('bitcoin');

// Entities may or may not have pricing data attached
$price = $entity?->getData('price_usd');
$tier = $entity?->getData('tier') ?? 'unranked';

echo "BTC: \${$price} — tier {$tier}";

// Arrow function for inline transforms
$slugs = array_map(
    fn(array $e) => $e['slug'],
    $client->search(vertical: 'movies', limit: 20)
);

// Retrieve multiple entities at once
$batch = $client->findMany(slugs: $slugs);