Hi there,

This module appears to not be updating twitter statuses every cron run... In fact, it only updated it when I created registered a new twitter account on the drupal site. Is there something I'm missing? You can view the site here: http://moddinghq.com (it's the block below Who's Online - ModdingHQ Tweets). The view I'm using is fairly straightforward, and is unlikely to be the source of the problem as the tweets shown in the profile pages aren't being updated either. Cron is being ran every 1 hour. No errors have been reported with the cron run.

The exported views data can be found at http://pastie.org/456661

Thanks for any help, this module is most promising.

- Wayne

Comments

watbe’s picture

Status: Active » Closed (fixed)

Played around with settings and guess what - all is well =)

Thanks for the excellent module and sorry to disturb you.

aschiwi’s picture

Hey watbe,

What exactly helped you when playing around with the settings? I have the same problem you had. I have a block showing tweets and it's not updating. the page on the user account page actually does have the latest tweets, but I kinda need the block to do the same ;)

Thanks
Anja

watbe’s picture

Can't remember for sure, but these settings were set in admin/settings/twitter

Import Twitter statuses - TRUE , Delete old statuses: NEVER.

And make sure that individual twitter account setups (in the account page) have import ticked.

This seems to work well for me, hopefully you can get it working as well :)

aschiwi’s picture

Hey thanks for your reply :-)
I got it working now by removing the uid argument from the block view, since I only want the one twitter account to show up for everybody.

LaurenH’s picture

I've checked "Import Twitter Statuses," and set "Delete old statuses" to "never," but I still seem to have trouble getting the Twitter feed to update unless I run cron.php while logged in. Am I correct in assuming that cron is only running with anonymous user privs? Is there a way to change this?

candygirl777’s picture

I'm also having the same problem - when I initially set up the Twitter block, it imported the statuses, but won't update, and I've tried everything above. Any help will be greatly appreciated!

candygirl777’s picture

Status: Closed (fixed) » Active
alastair’s picture

Subscribing. This is a problem for me too; I haven't managed to import any Twitter statuses to my site at all yet.

_adesmith’s picture

I too have tried the above, but to no avail. I even tried poormanscron as my host does not allow scheduled cron runs, but still no dice.

However I have found a work around by 'cheating'. It has proven to be 100% reliable for me, if all you want is the twitter feed & you're not too fussed over the aesthetics etc. Simply obtain the code for a widget from twitter.com (it's in their goodies section). Enter your account details, grab code & paste into a new block that you have created especially.

The widget's code does all the hard work, updates on page refresh etc, and works just like a feed. I suppose that's because it is a feed.

Like I said, it is not that bright an answer, retro-code even, but if you're stuck on a poor hosting deal like me, well...

YK85’s picture

subscribing

dhouse109’s picture

I ran into this problem just today and found a quick fix, but nothing in code to really patch it up.

I manually added the user I wanted tweets from to the {twitter_user} table. That solved it.

INSERT INTO `twitter_user` VALUES ($twitter_user_id_num, $twitter_user_screenname, NULL, 1);

Initially the table was empty. I added this same user using the Twitter Setup config, and saw the username again and again when I came back to the form. But when I started inspecting the queries generated by the cron hook, I found that the {twitter_user} table was empty, causing the cron_hook to think there were no users with twitter accounts to update.

I'm not sure what the cause of this is, since it seemed to be working before today for a while. I'm mostly not sure because I didn't set this site up initially...just found myself on it as it was being rolled out. I'm interested in finding out what went wrong though.

It should also be noted that the Alternate Api URL setting in the Twitter Setup config *must* be filled in, and defaulted to "twitter.com". I deleted this value just because it seemed from the language (being an alternate), that there was some sort of default that this field would override. Not the case however. Leaving it blank will cause an error during the cron job.

dhouse109’s picture

So I just found out my perception of how the Twitter Module works was wrong. It turns out the {twitter_user} table is populated by entering the user info while in the drupal user edit mode. That is, this info is associated with a drupal user account. So in my case the solution would have been to add the twitter user info to the root drupal user.

I wonder if I'm the only one who misunderstood the "Global User" account.

Brodingo’s picture

I was having a problem with statuses not updating. I made sure under admin>site config>twitter that 'import twitter statuses' was checked and then went to users>(myuser)>edit>twitter account and made sure 'import' was checked. then i ran cron and it refreshed with the most recent status.

Hope this helps someone.

ericquigley’s picture

I've tried everything under the sun - I can't get the module to update... sigh.

pauloamgomes’s picture

Hello, i have the following and similar problem but its related to retweets:

  1. Installed module with defaults
  2. Configured it with twitter account
  3. Run cron

it works only and only in the first time, after that, running cron, or invoking it directly (using supercron module) it not updates, making a capture i can verify that the problem is not with the module, since during cron it invokes twitter correctly, but for some reason twitter answers with old xml data, ex:

HTTP GET REQUEST

GET /statuses/user_timeline/pauloamgomes.xml?since=Wed+May+26+14%3A58%3A15+%2B0000+2010 HTTP/1.0
Host: twitter.com
User-Agent: Drupal (+http://drupal.org/)
(...)

HTTP RESPONSE

<?xml version="1.0" encoding="UTF-8"?>
<statuses type="array">
<status>
  <created_at>Sun Jun 06 10:10:56 +0000 2010</created_at>
  <id>15547356065</id>
   (...)

so for the answer i have has last update Jun 06 with is not true, because i have some retweets after that and that's the problem, because retweets are stripped from xml and json calls..as defined in http://dev.twitter.com/doc/get/statuses/user_timeline, to handle retweets it's possible to use the retweeted_by_me function.

phoenix’s picture

I have the same problem.
On my local machine the twitter module is importing new statuses. On dev and production it is not. I added some watchdog statements to log the whole cron process and the problem occurs when the response data is being decoded by json_decode.
On my local machine the decoded data is fine with the right twitter status id per status.
On the two other environments the twitter id of statuses is being changed and they all have the same id. Thus one twitter status gets updated all the time. And no new status is being inserted.

When checking php versions, I see a difference. Local: 5.2.11. On dev 5.2.0-8+etch16. Could this version difference make a difference in the json_decode function? Both version have as json version 1.2.1. Or is it a charset issue?

Thanks for your help!

phoenix’s picture

For now I have solved it this way: I abandoned json_decode and used an alternative parser.
Here is an example: http://drupal.org/node/392978
I used the parser mentioned on that page and now I can import statuses again.

The problem was the following. The twitter_ids consist of a number with 11 positions. After the json_decode they were all 10 positions and all set to 2147483647. One status got imported. After that the status with id 2147483647 got updated all the time. Resulting in the same item remaining as most recent status.

ericquigley’s picture

So, if one were to attempt #17, abandoning the json_decode for an alternative parser, does anyone know where one might look for reasonably straightforward instructions on doing so? Let's assume that one isn't much of a programmer.

Thanks to anyone who can help!

phoenix’s picture

The instructions are in the link I provided in #17

create this function (and give it whatever name you want):

function alternative_json_decode($content, $assoc=false){
                require_once 'json/JSON.php';
                if ( $assoc ){
                    $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
        } else {
                    $json = new Services_JSON;
                }
        return $json->decode($content);
    }

Then place this script in the "JSON" directory: http://pear.php.net/pepr/pepr-proposal-show.php?id=198 (under links > PEAR package file (.tgz)) (Unpack the package and you'll see a json.php file.)

ericquigley’s picture

Works beautifully! Thanks phoenix - your help is very much appreciated!

phoenix’s picture

Great to hear this is helping you too !

sebasje83’s picture

Maybe one of you know a answer to the following problem.... I installed several 6.xxx version of Twitter module but each version makes run cron fail... SO if Twitter module is installed and working then run cron does not work and therefore I had to delete Twitter module in order to get my run cron index my new content. Does anyone have a solution for this? Hope to hear from some of you.. Thanks in advance.

justinlevi’s picture

Priority: Normal » Critical
Issue tags: +update, +problem, +Twitter_id, +twitter update, +cron problem

I can confirm that this exact same issue is happening for me as well. Using the Devel and the supercron modules I can see the update statement trying to set the same ID each time.

I apologize if I'm missing something super obvious here, but the instructions for implementing an alternative json decode function still don't make sense to me.

1. My understanding is that I should add the following code to my template.php


function alternative_json_decode($content, $assoc=false){
                require_once 'json/JSON.php';
                if ( $assoc ){
                    $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
        } else {
                    $json = new Services_JSON;
                }
        return $json->decode($content);
 }

Then I add the JSON.php file to the JSON directory? Where is the JSON directory?

Any help is much appreciated.

Here are my first two update SQL statements showing the same twitter_id being set.

UPDATE twitter SET twitter_id = 2147483647, screen_name = 'apartfromwar', created_at = 'Wed Jul 07 05:00:46 +0000 2010', created_time = 1278478846, text = 'New post: Ordered List Test http://tinyurl.com/33rrkok', source = '<a href=\"http://drupal.org\" rel=\"nofollow\">Drupal</a>', truncated = 0 WHERE twitter_id = 2147483647
UPDATE twitter SET twitter_id = 2147483647, screen_name = 'apartfromwar', created_at = 'Mon Jul 05 17:44:02 +0000 2010', created_time = 1278351842, text = 'It\'s our last full day in the woods of WA state. The sun is shining, and it\'s a beautiful day for final shots. Busy day. - via @davidmill', source = '<a href=\"http://www.grouptweet.com\" rel=\"nofollow\">GroupTweet</a>', truncated = 0 WHERE twitter_id = 2147483647
Gilneas’s picture

Subscribing for the same issues.

@ justinlevi:
As far as I know Json is a webservice, so your json directory should be located somewhere on your webserver. If your Drupal installation is running on a managed server like mine there is no chance for this quick fix.

Am I wrong, or is somewhere a bugfix which might help me I didn't understand yet?

dooug’s picture

Version: 6.x-2.3 » 6.x-2.6

Drupal 6.17
Twitter 6.x-2.6

PHP 5.2.6
JSON 1.2.1

I am experiencing the same issues mentioned above. I am not sure I want to go messing around with JSON or PHP, because the post mentioned in #17 sounds like it is for <= PHP 5.1.x.

I tried disabling/enabling the module but it only pulled in the latest tweet.

beddoe’s picture

Same issue, resolved by the following cron entry: (runs every 5 minutes)

*/5 * * * * /usr/bin/curl http://www.beddoeconsulting.com/cron.php

Tweets can be seen here:
http://www.beddoeconsulting.com/content/bc-tweets

Wally

Gilneas’s picture

Trying this fix. Hope it works.

Gilneas’s picture

I'm Sorry it does not work for me. Any other suggestions?

dooug’s picture

beddoe,

Does running cron that frequently affect the system performance much? It might especially if there are many modules using the hook_cron. Or is every 5 minutes a safe option?

Gilneas’s picture

For my installations running the cron every 5 min I can say it is not a problem.

It shouldn't be less than 5 mins between the runs, because sometimes the cron takes some time and then two crons might be started at the same time.
This may slow down your server system.

Are there no new suggestions on this issue?

beddoe’s picture

No, the command takes milliseconds and should have no noticeable effect on overall system performance.

pcoucke’s picture

The number 2147483647 is exactly 2^31 and indicates an integer overflow. See also http://www.lullabot.com/articles/drupocalypse-now-or-dangerous-integer-h....

I have the issue that there's only one row in the twitter table and when I run cron, I see the content of this row changing but the id stays the same. The strange thing is that this only happens on our production servers and not on our local or testing environment. Our production servers are still 32-bit.

I use version 6.x-3.0-beta3.

steinmb’s picture

Status: Active » Closed (cannot reproduce)

A lot of different issues in this thread, and a lot of the code have changed. Closing this. Anyone that still got issues with this, pls create an separate issues.