Fatal error: Wrong parameters for Exception([string $exception [, long $code ]]) in /home/tulasira/public_html/drupal/sites/all/modules/twitter/twitter.lib.php on line 18

After setting up the twitter module...
When you create content and publish...
Appears in a blank page...

Kindly solve this...

Thank You,

Comments

Golem07’s picture

I am having the very same problem.

ytsuhako’s picture

i move my site rental server to local xampp.
so i have same error.

event reports
Unexpected error: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?

i enable openssl. so no error.

holdmann’s picture

Status: Active » Closed (works as designed)

It really helps!

just enable openssl module and get fun ;)

Golem07’s picture

Unlike the original poster I already get this error when trying to add a twitter account to a user.

I am on a shared host so I do not think I am able to configure php :( But on the other hand I also do not get the report mentioned above. Instead my site reports: "Unexpected error: Unauthorized" (type: twitter).

Golem07’s picture

So I understand that the issue is closed.

Does this mean that I have no chance of running twitter on D7 any more so long as I am on a shared host? Just asking since "just enable openssl module and get fun ;)" is not a statement which I find very clear. Thanks in advance.

holdmann’s picture

Have you any errors in error.log file?

If it contents just error represented above, try this scenario:

Modify "modules/twitter/twitter.lib.php". you should delete or comment Exception wrapper __construct() method, like this

/**
 * Exception handling class.
 */
class TwitterException extends Exception {
  /**
   * Overrides constructor to log the error.
   */
  /*public function __construct($message = NULL, $code = 0, Exception $previous = NULL) {
    watchdog('twitter', 'Unexpected error: @message', array(
      '@message' => $message,
    ), WATCHDOG_ERROR);
    parent::__construct($message, $code, $previous);
  }*/
}

So, now you should get another error indicating the source of the problem. Paste it here and i'll try to help.

Golem07’s picture

Thank you very much holdmann!

This was exactly the hint that I needed since unlike before I was nowredirected to a twitter error page indicating a problem with some token. I was able to solve the problem by starting over on the twitter side of the setup. Without your modification I would still have expected the problem to be caused by my Drupal or server set up.

Bricks and Clicks Marketing’s picture

I'm having this exact problem. After commenting the code you recommended, the error returns this:

Fatal error: Call to a member function get_auth() on a non-object in /home/warren/public_html/sites/all/modules/twitter/twitter.inc on line 12

This error occurs when creating a node, which until now had been automatically posted to Twitter.

What I've done so far: I uninstalled & reconfigured the Twitter & Oauth modules. I also reset the keys in the Twitter application. Maybe something in Twitter's API changed?

Thanks!

csc4’s picture

Status: Closed (works as designed) » Active

I don't understand - how can this be marked closed works by design when it's reporting an error with the parameters - surely it should have the right parameters, capture the error from Twitter and display it if it really 'works by design'?

Also I've got this problem too and it's taken down my cron which was working fine until I upgraded to 3.2 so I'm finding it hard to understand why a problem which wasn't fatal in 3.1 and is fatal in 3.2 'works by design'

If module OpenSSL is a dependency then shouldn't the project page say so, the documentation say os and shouldn't it be set as a dependency in the .info?

I've also looked and can find no module OpenSSL?

holdmann’s picture

OpenSSL is a php-extension.

It should be checked during module installation.

if (!extension_loaded('openssl')) {
  // abort install
}
Bricks and Clicks Marketing’s picture

The problem I'm having is on a site where it was working and now is not. So it's not an issue of a problem during install. What's the solution then?

newad_fr’s picture

Hi,

This may sounds obvious, but you must register your application first, otherwise you'll get the error. Navigate to the Twitter config page in your Drupal installation:
admin/config/services/twitter

You'll see a "register your application" link that will redirect you to Twitter. Fill up the form. Note that the "callback URL" you need to provide is listed in the Twitter config page of your Drupal site. Once the process is complete, copy/paste your "OAuth Consumer key" & "OAuth Consumer secret" back to your Drupal and voilà !!

Bricks and Clicks Marketing’s picture

All of that info is in there already and everything had been working fine - when an article was posted, a tweet went out. Now when an article is posted we get the fatal error I noted in comment #8.

mcartmel’s picture

Are you using PHP 5.2? This could possibly due to the fact that PHP < 5.3 only has two parameters to the Exception constructor.

Try this:

//parent::__construct($message, $code, $previous);
parent::__construct($message, $code);
Bricks and Clicks Marketing’s picture

Thanks - where would I edit that?

stg11’s picture

I'm running PHP 5.2 and getting the error. If PHP 5.3 is a requirement, this requirement should be listed on the project page.

stg11’s picture

answer to #15 is twitter.lib.php line 18

I changed as in #14 and now get
An error occurred when posting to Twitter: Read-only application cannot POST

stg11’s picture

After changing access on Twitter to Read/Write I now get this
An error occurred when posting to Twitter: Could not authenticate with OAuth.

stg11’s picture

I resolved #18 by clearing caches and deleting and re-adding my twitter account in Drupal. Posting successfully now.

Bricks and Clicks Marketing’s picture

I did the fix in #14 (thanks stg11 for telling me where), cleared the cache & reset the oauth keys - now I get no errors when posting, but a tweet doesn't go out either.

Tried changing the application type in Twitter to read/write instead of just read, still no tweet going out. Tried changing the Twitter API link in Drupal from "https://api.twitter.com" to "https://api.twitter.com/1/" to match the Request URI in Twitter, still nothing. The node type (blog) is selected at /admin/config/services/twitter/post and the default string format is "New post: !title !tinyurl".

What should I try next?

Bricks and Clicks Marketing’s picture

Some assistance please?

nobuyuki3’s picture

0、I don't know why, but the twitter Lobot remove my app setting from twitter webiste, so I registered my site again, and setting again.

1、I tried to change PHP ver from php5.2 to 5.3 using .htaccess.

2、I delete all the Cache on drupal site.

3、I removed my twitter account form my site, and re-add.

4、the last reason you should consider is, Callback URL, I use i18 for internationalization, it may effect for changing URL, then twitter aouth can not recognize URL collectly.

But the error is still remaining.....

syawillim’s picture

Same issue, everything was working fine yesterday. Added new content today and got the following "Fatal error: Wrong parameters for Exception([string $exception [, long $code ]]) in /home/...../...../sites/all/modules/twitter/twitter.lib.php on line 18".

Only change, yesterday updated to the following modules:

  • Display Suit 7.x-1.6
  • Profile2 Registration Path 7.x-1.10
  • Token 7.x-1.4
  • Wysiwyg 7.x-2.2
dwhutton’s picture

I have the same issue, which occurred out of the blue: one minute everything is working fine, the next minute I get the dreaded white screen every time a node attempts to post to Twitter.

No changes whatsoever were made in the codebase or the setup.

When I patch the code per #14 I get the message 'Unexpected error: Sorry, that page does not exist'. I'm re-saving an existing node and the log indicates that the save occurred normally.

nobuyuki3’s picture

#23
It may not the problem of the new modules, because I did not install any modules but the problem happened.

I noticed that I can not add any twitter account on my drupal site because of this error occured......omg

magpie5212’s picture

Similar to #24, I had a site which was working fine and then this started happening - the first time I noticed was when I got a call from one of my users late last night.

liliplanet’s picture

Got it fixed .. just reset the keys in your app, add the new settings to your twitter on drupal and all good :)

cbeier’s picture

Same here: A few days ago it was still working. Now there are only 500 errors when something is to do with the Twitter API.

In the last days, nothing has changed on this Drupal site (installed modules/updates, …)

Maybe Twitter has changed something …?

nobuyuki3’s picture

#28
yes, may be you re right.
Many users happened the problem "at the same time", it's quite strange.

artworker’s picture

Hi guys,
I have the same error:
Fatal error: Wrong parameters for Exception([string $exception [, long $code ]]) in /home/magicgla/public_html/glasnovations.com/sites/all/modules/twitter/twitter.lib.php on line 18

Now my cron can't run.

If I re-register and reset the keys in the twitter module, can anyone confirm that that will fix it?

newad_fr’s picture

Hi all,

I've tried all of the above suggestions, but I feel I'm moving from one error to another, without really knowing what's the problem/solution. Any real (reliable) solution from the developers? In the meantime, I disabled the module, cause it prevents cron from running correctly.

chris-cmfi’s picture

Same issue here. Had to disable the module because it disrupted cron.

robstead’s picture

Same here. Everything was working but now I get the 'wrong parameters' error. All the suggestions here haven't worked and I'm unaware of any changes at my end. A fix would be welcome.

Technikal’s picture

Sme problem with me as well, CRON is gagging

dwhutton’s picture

What worked for me was to re-install Twitter and Oauth following the exact set of steps described in this post:
http://drupal.org/node/1361938#comment-5411616

Now everything is working fine.

Leeteq’s picture

Status: Needs review » Active

Can anyone else confirm if they too get this fixed from the description mentioned in #35?
(And please confirm if you are running the latest -dev release or which version you are using.)

Quoting from there:
( #1361938: Not posting to Twitter )
(obviously, some steps are irrelevant for existing accounts, but seems like the point is to start fresh, test with a clean/new drupal site or uninstal/reinstall)

1) Download and install Twitter module (activating only main module, not sub modules)
2) Create Twitter App
3) Change App permissions to Read & Write
4) Reset Application keys to obtain new consumer key & secret
5) Add Twitter account in Drupal User admin (/user/[user_number]/edit/twitter)
6) Run cron and check that twitter statuses are shown in user area (/user/[user_number]/tweets)
7) Download and install OAuth module
8) Add Twitter App Consumer key & secret to Drupal > Configuration > Web Services > Twitter
9) Activate Signin with Twitter submodule
10) Log out of Drupal and Sign back in using Twitter account (it works)
11) Activate Twitter Post & Twitter Actions sub modules
12) Choose content types to automatically post in Drupal > Configuration > Twitter > Post
13) Add new content
14) Check twitter - it works!!

"NB: It is not necessary to sign in to the Drupal admin with your Twitter account to have posts automatically post to Twitter."

Leeteq’s picture

Version: 7.x-3.2 » 7.x-3.x-dev
Status: Active » Needs review
dwhutton’s picture

Status: Active » Needs review

I should have mentioned, the cause of this problem is apparently a change in Twitter's API -- which is why the problem just appeared out of the blue for many people. This is also why a clean install seems to be needed.

fizk’s picture

Status: Needs review » Closed (duplicate)
laur3ntlapo’s picture

I have the same problem, tried all the solutions here and nothing worked. I have 5.2 and openssl enabled

barrabasah’s picture

me to Wrong parameters for Exception([string $exception [, long $code ]]) new instalation

kenyan’s picture

Status: Closed (duplicate) » Active

Re-opening.
I don't see how this is a duplicate of the 5.3 php check.
I running this dev version anf have followed all possible solutions on this page.
Thing is this error still shows up even when supposedly all fixes have been commited.

I'm running latest version Oauth too.

fizk’s picture

kenyan, are you running php 5.3?

xurizaemon’s picture

Status: Active » Closed (duplicate)

@kenyan, "Fatal error: Wrong parameters for Exception" really is a dupe of #1814642: Invalid handling of exceptions causes fatal errors on PHP5.2. This error occurs only if the module is used on PHP5.2 or earlier and throws an exception.

I'm committing that solution shortly; please test the next available module release for the fix.

robstead’s picture

Thank you. The latest update fixed the problem for me. It's much appreciated.

xurizaemon’s picture

Thank you for confirmation that the fix worked for you, Rob. It's always welcome.

kenyan’s picture

You are correct. I was totally unaware my client was on 5.2 (my fault).
This fixes the issue.
Thanks much.