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?