"Fatal error: Uncaught DisqusException: [0]: There was an error querying the Disqus API. thrown in ...modules/disqus/disqus.php on line 345"

Successfully exported several batches of comments previously from drupal to disqus, but now all I get is the above error.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

CinemaSaville’s picture

Priority: Normal » Critical

I get the same message- only it's line 341

Dash’s picture

I just get a blank page - looking at the disqus account, it imported 2 comments from 6 years ago and that's it!

RobLoach’s picture

Title: fatal error on export » Uncaught DisqusException on export

6 years ago? Wow, that's pretty old..... Just keep on trying to export it; Would be great to provide more error correction and discovery. Any help with that would be appreciated.

Dash’s picture

Nothing in the logs, except this:

PHP Fatal error: Uncaught DisqusException: [0]: There was an error querying the Disqus API.\n\n thrown in [...]/sites/all/modules/disqus/disqus.php on line 345, referer: [...]/admin/settings/disqus/export

blank page every time!

Dash’s picture

well I'm unable to find anything on the web about the problem, except suggestions that the user API key is incorrect, which it can't be because comments made on the site go to disqus...

At a loss really, don't want to have two comment systems at the same time!

petermallett’s picture

FileSize
4.7 KB

Back when the conversation at http://drupal.org/node/269010 started I began working on a drupal-> disqus export module but before I was able to complete it the disqus_migrate in 6.x-1.x-dev was patched to include this functionality.

Unfortunately we tried to use that version and ran into similar issues... so, I went back and finished up what I was doing (I couldn't see a timely way to fit my implementation into disqus_migrate, sorry : / ).

Here it is, give it a go. It uses batch api and will test your disqus api connection when you click the 'Export' tab to let you know if your api key is working before you try to export.

It will install along side of disqus and disqus_migrate -- I did snag the schema & slightly modify it from disqus_export-dev, thx for that ;)

Dash’s picture

That's fantastic! You are a star, thank you!

RobLoach’s picture

If we get this into patch-form, we could commit it to the module so everyone could benefit! :-)

Think instead of Disqus Migrate, we should split it into both Export and Import modules? Might make sense... Thanks! It looks really good :-) . Like the addition of Batch API.

RobLoach’s picture

Status: Active » Needs review
chrissearle’s picture

I've been trying the code from #6 - it sees all comments but doesn't transfer all.

Of the 22 blog comments I get 12 transferred.

Debugging the _disqus_export_process_node method - I threw in watchdog logging.

It does send all 22 comments. But for 10 of them I get a Disqus exception with the message "There was an error querying the Disqus API".

Always the same 10.

Note - that I never see these errors otherwise - so the $context['results'][] = $exception->getMessage(); line in the catch handler isn't getting back to the results page.

EDIT:

Looking in the database - the 10 that fail are the 10 that have no entry in the name field of the comment table.

Am guessing this is causing issues here:

$post = $disqus->create_post($thread_id, $comment->comment, $comment->name, $email, $options);

So - any suggestions what should be set for Anonymous comments here? I'm new at disqus - so I'm not sure what it would like - perhaps the string Anonymous?

chrissearle’s picture

Further thoughts.

http://groups.google.com/group/disqus-dev/web/api-1-1#create_post suggests that both name and e-mail are required.

If name is blank - we could set anonymous.

E-mail is worse - what should we set for the e-mail? I'm guessing it would have to be site related - but setting the site admin e-mail seems odd.

Should we prompt at import? Other ideas?

chrissearle’s picture

OK - had to test it ;)

Attached version (both a zip and a git diff patch) does the following:

1) If the name field is blank it grabs the name of the anonymous role as the name
2) It has a field on the export form for specifying which e-mail to use at export if we can't find anything else.

With this I got all 22 comments ported over to disqus ;)

RobLoach’s picture

I like it a lot, Chris! Is there anything to note before its committed?

petermallett’s picture

#12, awesome, I was just coming here to do just that, wish I had more time to keep up with this :P

#13, that was the last issue I was looking at in the free time I could snatch over the last week, the only issue I still see is that disqus_anonymous_email_address needs to default to something (I used 'anonymous@example.com') because the create post call will still fail if it's not filled in.

chrissearle’s picture

Yes. Agree with #14.

1) I don't default the e-mail address to anything at first run. It will remember what was set (variable_set/variable_get) - but the first time it isn't set. What about something like no-reply@domain_of_the_admin_e-mail ?

2) It's also not required. This due to the fact that it may be totally irrelevant if you don't allow anon comments. I suspect that we can find out if it's needed - but it starts getting complex - only require it if you check a checkbox for a type that has anonymous comments etc? Perhaps just set it mandatory always ;)

Biggest irritation now is that the imported comments are not owned by me (either because that's how it works or because I have too many e-mail addresses and they didn't match between drupal and disqus at import). And the "Claim your comments" link in disqus isn't working on the imported comments. But I suspect that's much more likely to be a disqus issue than for this module ;)

Dash’s picture

Excellent, #12 got the remaining comments for me!

#15 - it took a few goes, but I managed to claim all of my admin comments in the end, had to set up a second Disqus account for my other email address to get the others!

chrissearle’s picture

Not sure how to claim them ;)

When I imported - my disqus account (which was just for testing to start with) had a testing e-mail. I've since replaced it with my main one - since I decided to go with the change.

So - the disqus account e-mail matches the e-mail of the posts.

When I hit the claim link it just takes me to my profile page - with no posts.

Am going to see if disqus support can help ;)

rootwork’s picture

Status: Needs review » Reviewed & tested by the community

This seems to have worked for me, and the others in the thread as well -- time for a commit?

And, for that matter, the dev seems stableish enough to post it as a beta release...

rootwork’s picture

On a couple of sites with a bunch of comments, I had to run this a few times for all of the comments to be imported -- it would just hang and not progress any further.

Happily, it *did* work, and didn't result in any duplicate comments.

I really think the ability to import Drupal comments to Disqus is a big step (and something folks have been posting about for awhile) so even if it's an alpha or beta release, I think it would be useful to release it.

deverman’s picture

This keeps hanging for me can never get it to go very far. I tried halving the batch size from 10 to 5 and it did not help. after that I tried a batch size of 1 and also did not work. Still investigating.

Patrick Mowrer’s picture

Attempting to run the this export module with both 1.6 and dev, I get the following at the export screen (and no form):

warning: Parameter 2 to disqus_admin_export_form() expected to be a reference, value given in ..Drupal/includes/form.inc on line 376.

Any ideas what could be causing this?

hankpalan.com’s picture

I get this error on the 6.x-1.x-dev version: Fatal error: Uncaught DisqusException: [0]: There was an error querying the Disqus API. thrown in public_html/sites/all/modules/disqus/disqus.php on line 345

The first time I tried to export it exported only 1 comment there are 17 other comments that won't export. I've tried uninstalling and re-installing the module with no effect.

And just to clarify, the 6.x-1.x-dev now has the export module included in it as disqus migrate?

Gabriel R.’s picture

Subscribe.

bkno’s picture

Is there a way to see the total number of comments that have made it over to Disqus?

I keep getting the "Uncaught DisqusException" on line 345 error, but I keep re-running the script. Will the export tell me it's finished at some point, or just throw the error even when it's done?

These exports are not showing up on imports.disqus.net and at the moment I can't see a way to track progress.

bkno’s picture

I've noticed that when the export script comes across a trackback the script breaks and throws the exception. (Trackbacks probably in my comments table because I migrated site in question from WordPress to Drupal). When this happens the export script never gets any further as it's processing them in timestamp order, but if I delete the trackback then the export script will proceed until it hits the next one. The trackbacks don't have an email address set which is probably causing the problem.

jrowny’s picture

Just as a note, I had to run apt-get install php5-curl. I know mostly everyone has this installed, but I didn't and I got an error.

But i was able to get 62 comments over to disqus! Thanks so much! It worked perfectly for me :)

hankpalan.com’s picture

I can confirm that If a comment has the email field blank it causes this error, I just went in and put a default email address in those that didn't have it filled out and it worked perfectly!

Rob_Feature’s picture

Status: Reviewed & tested by the community » Needs review

Hmm...I haven't had luck getting all the comments using #12. I originally only had 25 comments on the site (all by registered users) and, on first run, it exported 5 of them....then, no matter what I did, it isn't exporting the rest.

So, no luck on my end quite yet...going to mark this as needs review since it sounds like others may be having issues as well.

a_c_m’s picture

For what us it is, i've modded my disqus.php to give a little extra info when it throws this error.

Fatal error: Uncaught DisqusException: [0]: There was an error querying the Disqus API. (Array
(
    [url] => http://disqus.com/api/get_thread_by_url/?url=http%3A%2F%2Fwww.domain.com%2Fnode%2F56511&user_api_key=SECRET&forum_api_key=SECRET&api_version=1.1&
    [http_code] => 0
    [header_size] => 0
    [request_size] => 0
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0
    [namelookup_time] => 3.5E-5
    [connect_time] => 0
    [pretransfer_time] => 0
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => 0
    [upload_content_length] => 0
    [starttransfer_time] => 0
    [redirect_time] => 0
)
)

So its not the creation of the thread thats the problem, or the creation of the post, but the check to see if a thread already exists on disqus?

#987258: disqus_migrate improvements may help, as it reduces the number of these requests that get made (or will once i've made the patch).

davidseth’s picture

By applying the patch at: http://drupal.org/comment/reply/987258/4000314#comment-4000314 it fixed this error for me.

But instead of skipping anonymous comments I changed the following (disqus_migrate.admin.inc):

    if (empty($mail) || empty($name)) {
      continue;
    }

into:

    if (empty($mail)) {
      $mail = 'anon@happychild.com.au';
    }    

    // Disqus requires both mail and name, if we don't have them, skip for now.
    if (empty($name)) {
      $name = 'Anonymous';
    }   
RobLoach’s picture

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

Version: 6.x-1.x-dev » 6.x-1.9

Having the same error with 6.x-1.9 version of the module. Still not fixed?

rootwork’s picture

@netikSEO This was marked as a duplicate issue, so it won't show up for most people in the issue queue.

I haven't noticed this still happening, but if it is for you, I'd re-open the issue linked in #31 and provide as much info as you can.

netikseo’s picture

Hmmm, this thread talks about specific error I have and not about "disqus_migrate improvements", so I thought it's more appropriate here. OK, I will post in the mentioned thread. Sorry...