1. Go to this page and download the library: Download usman/reddit-php-api 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/ */
usman / reddit-php-api example snippets
/**
* This demonstrates how to authenticate with Reddit and send api requests
*/
/*
* First you need to make sure you've used composers auto load. You have is probably
* already done this before. You usually don't bother..
*/
//
exit();
} elseif ($reddit->hasError()) {
echo "User canceled the login.";
exit();
}
//if not authenticated
$url = $reddit->getLoginUrl();
echo "<a href='$url'>Login with Reddit</a>";
// By constructor argument
$reddit=new Usman\Reddit\Reddit('app_id', 'app_secret', 'xml');
// By setter
$reddit->setFormat('xml');
// Set format for just one request
$reddit->post('v2/people/~/shares', array('format'=>'xml', 'body'=>$body));
// By constructor argument
$reddit=new Usman\Reddit\Reddit('app_id', 'app_secret');
$reddit->get('v2/userinfo');