Enter any subreddit to see the latest posts — pulled live from Reddit's API.
// Step 1: Get a Reddit token from ThoughtLab
$ch = curl_init('https://thoughtlab.cloud/v1/token');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer sk_live_...'],
]);
$token = json_decode(curl_exec($ch), true)['token'];
// Step 2: Fetch latest posts from r/programming
$ch = curl_init('https://oauth.reddit.com/r/programming/new?limit=25');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: bearer $token"],
]);
$posts = json_decode(curl_exec($ch), true);