REST API for DM is not registering updated permissions (RWD)


#1

I’m using application-only authentication and have set the permissions to Read, Write & Direct Messages. It’s been well over 30 minutes & I’ve invalidated my access token. I’ve tried re-creating my consumer key and secret. I’ve cleared my browser’s cache. I’ve done just about everything I can possibly think of and I think the API is incorrectly registering my application permissions.

Very basically, my successful API call for recent tweets in PHP is as follows:

$cj = curl_init();
$url = ‘https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=mediatemplehelp&count=200’;
curl_setopt($cj, CURLOPT_URL,$url);
curl_setopt($cj, CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($cj, CURLOPT_HTTPHEADER, array('Authorization: Bearer '.$_SESSION[‘token’]));
$result = objectToArrays(json_decode(curl_exec($cj)));
curl_close($cj);

This produces great results and shows all recent tweets. Using the following code for DM, I get a “Your credentials do not allow access to this resource” error.

$cj = curl_init();
$url = ‘https://api.twitter.com/1/direct_messages.json?count=1&page=1’;
curl_setopt($cj, CURLOPT_URL,$url);
curl_setopt($cj, CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($cj, CURLOPT_HTTPHEADER, array('Authorization: Bearer '.$_SESSION[‘token’]));
$result = objectToArrays(json_decode(curl_exec($cj)));
curl_close($cj);

I’m really confused here because I’ve given it complete permission to access that resource. Is the documentation wrong? Does this not work for application-only authentication?


#2

Direct messages aren’t available via app-only auth – direct messages pertain to users and are only available in user-based authentication contexts where the access token that was negotiated has permission for direct message read access associated with it.