0

I am trying to setup twitter module for Drupal 7 on my localhost. I followed the installation instructions as given in Twitter 7.x installation guide. I followed steps until "Add Twitter accounts" when i start getting this error.

Could not obtain a valid token from the Twitter API. Please review the configuration.

The dblog has the following information:

exception 'TwitterException' with message 'Bad Request' in C:\wamp\www\test_twitter\sites\all\modules\twitter\twitter.lib.php:142 Stack trace: #0 C:\wamp\www\test_twitter\sites\all\modules\twitter\twitter.lib.php(101): Twitter->request('https://api.twi...') #1 C:\wamp\www\test_twitter\sites\all\modules\twitter\twitter.lib.php(51): Twitter->auth_request('https://api.twi...', Array) #2 C:\wamp\www\test_twitter\sites\all\modules\twitter\twitter.pages.inc(336): Twitter->get_request_token() #3 C:\wamp\www\test_twitter\includes\form.inc(1464): twitter_auth_account_form_submit(Array, Array) #4 C:\wamp\www\test_twitter\includes\form.inc(860): form_execute_handlers('submit', Array, Array) #5 C:\wamp\www\test_twitter\includes\form.inc(374): drupal_process_form('twitter_auth_ac...', Array, Array) #6 C:\wamp\www\test_twitter\includes\form.inc(131): drupal_build_form('twitter_auth_ac...', Array) #7 C:\wamp\www\test_twitter\sites\all\modules\twitter\twitter.pages.inc(130): drupal_get_form('twitter_auth_ac...') #8 [internal function]: twitter_user_settings() #9 C:\wamp\www\test_twitter\includes\menu.inc(517): call_user_func_array('twitter_user_se...', Array) #10 C:\wamp\www\test_twitter\index.php(21): menu_execute_active_handler()

11 {main}

I also have oauth module installed as given in the requirements.

Additional info:

  • My machine accesses internet via a proxy server and i do have proxy settings given in settings.php file. Not sure why it should cause problems.

  • I was able to run twitter API commands using twitteroauth library in a standalone application. It was throwing errors before i gave it the proxy settings for curl.

Can anyone help?

7
  • Is SSL working on your local install? – enzipher Apr 19 '13 at 23:27
  • I doubt its working. I do have php_openssl extension enabled. I'll double check that. – Ranjan Apr 20 '13 at 6:20
  • Additionally, the stable version has an issue when trying to authenticate an account. You need to use the dev version in order for that to work (although it doesn't seem that's your current issue). – enzipher Apr 20 '13 at 6:46
  • @enzipher I followed instructions here and now i can access my localhost via https. I'm still getting the same error. Any more pointers? – Ranjan Apr 20 '13 at 7:15
  • Difficult to say what it could be, but I would double check the app setup and the anywhere domains. You might need to have a vhost domain such as 'mysite.local' for the app. – enzipher Apr 20 '13 at 8:07
1

I actually had a lot of trouble setting the Twitter module up on my localhost for testing, so I just created a blog post about how to set that up, that includes some tips on doing this with localhost: http://drupalwoo.wordpress.com/2013/04/22/how-to-show-tweets-from-your-twitter-account-on-your-drupal-website/

Here are the couple of things that I think my be relevant for you to check:

  1. If you’re testing on localhost, use the following urls for your website and callback URLs (don’t worry, these are just placeholders, and your drupal site will send the correct callback URL when it connects):

    Website URL: http://127.0.0.1:8000/twitter/oauth
    Callback URL: http://127.0.0.1:8000/twitter/oauth
    
  2. If you’re still getting errors when testing with localhost, make sure the version of the module you’re using has the patch #5 on this issue queue: http://drupal.org/node/1924478#comment-7260928 (if you have an older version of the module, prior to the incorporation of the patch, get the latest stable/dev release that includes it and uninstall and install the module)

6
  • I was logged in to my twitter account in the same browser all the time. Dint help. :( – Ranjan Apr 20 '13 at 6:18
  • Also, did you check that the 'Website' and 'Callback' URLs on the twitter application match what's listed in the settings tab of the Twitter module? They all have to match... – Boriana Ditcheva Apr 20 '13 at 20:46
  • yeah.. the callback urls were configured as given in the installation guide.. – Ranjan Apr 21 '13 at 16:00
  • Have you figured this out yet? What website and callback URL are you using in your dev.twitter.com application configuration? I just realized you're trying to set this up for localhost. – Boriana Ditcheva Apr 22 '13 at 16:10
  • In any case, I've edited my answer with some additional ideas and what may be a helpful blog post. Good luck! – Boriana Ditcheva Apr 22 '13 at 17:49
0

There is some change in twitter api. I was also facing some issue while connecting twitter. The Patch has been applied by the module maintainer and so either update your module or go through this issue and apply the patch. This patch works fine http://drupal.org/node/1924478#comment-7260928

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.