How do I check my inbox messages with the Reddit API?

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....

​

Posted Apr 1, 2019, 10:02 AM UTC

52
nmtake•

The request should be sent to oauth.reddit.com instead of www.reddit.com. Although I don't know PHP, I think the code should be (assuming your access token $this->accesstoken is valid)

$url = 'https://oauth.reddit.com/message/inbox.json';
$params = array ('after' => null, 'before' => null, 'limit' => 10, 'show' => 'all');
$headers = array("Authorization" => "bearer $this->accesstoken", "User-Agent" => "yourappname by [u/yourname](/u/yourname)");
$response = $this->request($url, $headers, $params, 'GET');
print_r($response); 
2
HashDivyaOP•

Thank you.
But it's working fine with oauth.reddit.com , It was the problem with accesstoken.

1