1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.4 Run Feeder cron job manually?

Discussion in 'XenForo Questions and Support' started by Allpar Dave, Jan 16, 2015.

  1. Allpar Dave

    Allpar Dave Member

    I have a news system on my site using WordPress and would like to run Feeder manually to collect news when it's posted. I have a WordPress plugin that automatically runs a script whenever a post is made, and it would be easy to hook in a command to run all RSS feeds right away if I knew how the !@$^*! that could be done. I suspect this is easy but I've searched the forums a few times and looked at the cron jobs page and can't figure it out. This would be much more efficient than having a dozen cron jobs running every 10-30 minutes "just in case" and would also get the news out faster (as in, instantly).

    I tried looking into deferred.php but can't figure out where the “feeder” script is.

    Is this something as easy as I suspect it is?
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Which feed are you referring to?

    Is this for content being imported into your forum or your forum RSS feeds being displayed on other pages/sites?
     
  3. Allpar Dave

    Allpar Dave Member

    Content being imported in via RSS. I tried to find a way to do it via WordPress plugin but did not. At first I just did the main feed but now I have news coming in by category (each category has its own RSS feed) to individual forums. TMI? and thanks for the quick reply. Gosh, I'm not in InvisionLand any more!
     
  4. Brogan

    Brogan XenForo Moderator Staff Member

    How would you know when to run the import based on an external feed being updated with new content?

    That's why it is done via a cron task.
     
  5. Allpar Dave

    Allpar Dave Member

    Because there's a thingie in WordPress that runs when you post and I am tied into that anyway to generate static "recent news" includes.
     
  6. Mike

    Mike XenForo Developer Staff Member

    See the class XenForo_CronEntry_Feeder. That is what is triggered by the cron.
     
  7. Allpar Dave

    Allpar Dave Member

    Oh, I see. I can run /directory/library/XenForo/CronEntry/Feeder.php from shell…, right?

    Edit: it looks as though I can run that from shell but not from a browser. I am using the Webhooks plugin for WordPress and will see if that works even if I can't do it from a browser (it can essentially hit a URL). If that fails I will see if I can trigger the running of the Feeder.php file from the existing php file I run when a news item is posted.
     
    Last edited: Jan 16, 2015
  8. Mike

    Mike XenForo Developer Staff Member

    No. The code in question can only be run within the XF framework (once it's started up). You would need to custom develop a script to call the necessary part of the API. (You could base the start up code on deferred.php and then call the necessary method to start the feed import.)
     
  9. Allpar Dave

    Allpar Dave Member

    Oh. Dang it. Much more work than I thought it would be. I'll take a look at deferred.php, thanks for the tip.
     
  10. Allpar Dave

    Allpar Dave Member

    Gosh, this deferred.php is a small script (to your credit). But I can't figure out what part to hardcode and what part to ignore.

    I am guessing I need to hardcode the second line to initialize($fileDir.'./library/Feeder/',$filedir); ?

    XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
    XenForo_Application::initialize($fileDir . '/library', $fileDir);
     
  11. Mike

    Mike XenForo Developer Staff Member

    Custom development is really beyond the scope of our official support. If you have any further questions, I'd recommend posting in the development forum.

    However, I will say that if you're putting the file in the root XF directory, you can use the code up until (and including):
    Code:
    $dependencies->preLoadData();
    Then after it just call:
    Code:
    XenForo_Model::create('XenForo_Model_Feed')->scheduledImportTimeLimited(15);
     
  12. Allpar Dave

    Allpar Dave Member

    Thanks. If that fails I will indeed try posting in development. I appreciate your help.
     
  13. Resolution

    Resolution New Member

    In a similar vein, is it possible to code a cron job to import the contents of an .xls file from an external website into the database?

    I've got something working locally which takes a copy of an .xls file stored on someone else's website (using .php fopen/fwrite) , and then read/display the contents (using PHPExcel - Home) but ideally I would have thought it would be better to use XenForo built in code? My code does not seem to work when added into XenForo for some reason.
     
  14. Mike

    Mike XenForo Developer Staff Member

    Your best bet may be to post in the development discussions forum with specific questions or problems.
     

Share This Page