HashDivya

u/HashDivya




r/redditdev•

I Had tried with the documented api and the code is like:

​

$url = 'https://www.reddit.com/message/inbox.json';

$fields = array (

'after' => null;

'before' => null;

'limit' => 10,

'show' => 'all'

);

$header = array("Authorization:$this->accesstokentype $this->accesstoken");

$credentials = $this->clientid.':'.$this->clientsecret;

$useragent = ' by /u/' . $this->username;

$response = $this->request($url, $fields, 'GET',$header,$credentials,$useragent);

print_r($response);

What am I missing here?

Thany you....

​

52





r/redditdev•

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://oauth.reddit.com/api/me');

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');

curl_setopt($ch, CURLOPT_USERAGENT, ' by /u/' . $username . ' (Phapper 1.0)' );

$headers = array();

$headers[] = 'Authorization: bearer 239929*****';

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);

print_r($result);

curl_close ($ch);

​

​

​

What is missing in the above code?

42

r/redditdev•

function access_token() {

$this->username = readline("Enter username: ");

$this->password = readline("Enter password: ");

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,"https://www.reddit.com/api/v1/access_token");

curl_setopt($ch, CURLOPT_USERPWD, $this->clientId . ':' . $this->clientSecret );

curl_setopt($ch, CURLOPT_POST, 0);

curl_setopt($ch, CURLOPT_POSTFIELDS,"grant_type=password&username=$this->username&password=$this->password");

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$server_output = curl_exec ($ch);

$response = json_decode($server_output , true);

cu

22



You've reached the end of this feed.