Today, I was trying to get Drupal to automatically announce new posts on Twitter. To do this, I had to install the Twitter and OAuth modules. Following instructions, I created an application on Twitter and linked my Drupal account to it configuring it to announce new posts upon publishing them. However, this did not work as I ran into the following long-winded error message in the logs:
exception 'TwitterException' with message 'Read-only application cannot POST' in sites/all/modules/twitter/twitter.lib.php:284 Stack trace: #0 sites/all/modules/twitter/twitter.lib.php(379): Twitter->request('http://api.twit...', Array, 'POST') #1 sites/all/modules/twitter/twitter.lib.php(224): TwitterOAuth->auth_request('http://api.twit...', Array, 'POST') #2 sites/all/modules/twitter/twitter.lib.php(180): Twitter->call('statuses/update', Array, 'POST', true) #3 sites/all/modules/twitter/twitter.inc(107): Twitter->status_update('New post: Test Story ...') #4 sites/all/modules/twitter/twitter_post/twitter_post.module(101): twitter_set_status(Object(TwitterUser), 'New post: Test Story ...') #5 [internal function]: twitter_post_node_insert(Object(stdClass)) #6 includes/module.inc(823): call_user_func_array('twitter_post_no...', Array) #7 modules/node/node.module(1134): module_invoke_all('node_insert', Object(stdClass)) #8 modules/node/node.pages.inc(406): node_save(Object(stdClass)) #9 includes/form.inc(1443): node_form_submit(Array, Array) #10 includes/form.inc(854): form_execute_handlers('submit', Array, Array) #11 includes/form.inc(374): drupal_process_form('news_node_form', Array, Array) #12 includes/form.inc(131): drupal_build_form('news_node_form', Array) #13 modules/node/node.pages.inc(66): drupal_get_form('news_node_form', Object(stdClass)) #14 [internal function]: node_add('story') #15 includes/menu.inc(516): call_user_func_array('node_add', Array) #16 index.php(21): menu_execute_active_handler() #17 {main}
As the message indicates, I apparently did not have the right permissions set in the Twitter application. Going there, I switched the setting from Read only to Read and Write and saved my changes. Testing my post again, I unfortunately ran into the same error again. I ran around in circles for a while resetting my OAuth keys and so on, all to no avail. I even waited for a while in case my change had not propagated due to a caching issue. No luck.
While I eventually just recreated the application, I reckon that the fix could have been far simpler. There are three crucial locations to be cognisant of:
- In the Twitter dev site app, look under the Settings tab for the Application type area. This, as mentioned above, should be set to Read and Write
- Under the Details tab, look for the Your access token section. If the Access level here does not show Read and Write, click on Recreate my access token to do so.
- Finally, log into your Twitter account and navigate to the apps area of your settings page. Your app should specify that you have read and write access. If not revoke access and recreate the link.
If salvaging the existing configuration does not work, delete the app and restart the entire process with the above areas in mind. It shouldn't take long!
I hope this helps!
- Log in to post comments