PHP code example of jord-jd / php-reddit-search

1. Go to this page and download the library: Download jord-jd/php-reddit-search 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/ */

    

jord-jd / php-reddit-search example snippets


use JordJD\RedditSearch\RedditSearcher;

$searcher = new RedditSearcher(
    $accessToken,
    'php:your-application:v1.0 (by /u/your_reddit_username)'
);

$results = $searcher->search('PHP programming language', [
    'subreddit' => 'PHP',
    'sort' => 'top',
    'time' => 'year',
    'limit' => 25,
    '

$searcher = new RedditSearcher(
    $accessToken,
    $userAgent,
    function (string $url, array $headers, int $timeout): string {
        return $yourHttpClient->get($url, $headers, $timeout);
    },
    10
);