Support » Plugins » Using cron job to run Blogger Image Import

  • Resolved Huwman


    Hi there, I’ve tried my best to use the search function and google to answer this, but I couldn’t quite find one.

    I’m *this* close to finishing my blog setup but I have one minor hurdle to go before I’m done. I’ve just got the Sony-Ericsson K800 phone, which has a nifty photo blogging feature. Though, as you may have heard, it’s only compatible with Blogger.

    I’ve installed FeedWordPress and set up a cron job to import new posts from the blogger account every hour and this works perfectly. However, the pictures also need to come across as Blogger does not allow hot-linking.

    So, I have installed Blogger Image Import, which also does exactly what it said it would, but only when I log in to my account and run the script from the dashboard. What I want to do is have this script scheduled to run automatically 5 minutes after the feedwordpress script runs.

    I don’t really know that much about php, but I think I can see at least two ways of doing this;

    a) stripping out the code from “blogger-image-import.php” that actually performs the import, placing it in another php file and cron jobbing that every hour.


    b) stripping out the import code and inserting it into the “update-feeds.php” file (the feedwordpress script). So that it’s run all as part of the same file.

    If either of these would work, my problem would be that I don’t know which parts of the files I’d need to edit. So any help would be greatly appreciated.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Sorry for not replying to your comment on the blogger-image-import site, but I see you have found another forum for your question (probably better as more people can help).

    The image import script is not all that complicated and most of the code is borrowed from the core WordPress scripts, with some changes. Adding that to the feedwordpress script probably wouldn’t be too hard, though I don’t know anything about the feedwordpress script.

    You should find it easy to use the Blogger Image Import script somewhere else. All the code is in the function ko_blogger_image_import_process which takes only two parameters, the number of images to import and whether to apply the changes. If you included that code and called that function with a sufficiently large number it should automatically import any new images since the last time you ran it.

    If you do add this to your update-feeds.php or need help with it please reply here and leave a comment about your changes on the Blogger Image Import page.

    Thanks for the reply Poco, I’ll try and see if I can work it out and post the changes.

    Feel free to delete my comment from the BII page if you want, I realised that I shouldn’t have asked any support questions there so I came and posted this thread here.

    I may be closing in on a solution, but now I’m getting php errors, which may as well be written in greek for all I understand.

    I have edited the tail end of the blogger-image-import.php file to look like
    (remove the s)

    but when the server runs it, it returns an error of

    PHP Fatal error: Call to a member function on a non-object in ../wp-content/plugins/blog-img-import.php on line 246

    line 246 is
    $words = $wpdb->get_results(“SELECT ID, post_content FROM $tableposts WHERE post_status = ‘publish’ AND post_date < ‘$now'”);

    which I have not altered at all.

    any thoughts?

    Right, I have no idea what I’m doing so I’m giving up, for now. If anyone can solve this, please help, it’s driving me up the wall.


    Hmmm, yes, that code uses some globals that are expected to be available when executed by a plugin. I guess the way you are using it they are not.

    I don’t know much about how the feedwordpress plugin is configured or executed (I assume this is the plugin to which you refer

    It looks like you want to be careful about where insert the calls to the Blogger Image Import. Including that file inside update-feeds.php might not be enough, or you may want to insert the call to ko_blogger_image_import_process somewhere else in update-feeds.php.

    I notice on the feedwordpress site there is a feedwordpress_update_complete action that might be exploited for this purpose.

    I have not tried it, but if I did (I might try when I get more time) I would keep the blogger-image-import.php as-is with the addition of an action handler for feedwordpress_update_complete. Maybe at the bottom, after the add_action(‘admin_menu’) you could add something like the following. I am hoping that function will be called when feedwordpress is complete. When I get a chance I may try this myself, and I will report back if you haven’t already.

    function ko_blogger_import_feed_complete()
    ko_blogger_image_import_process(10, true);

    add_action(‘feedwordpress_update_complete’, ‘ko_blogger_import_feed_complete’);


    Again, thanks for your time,

    I’ve decided not to try and combine the files to help with any upgrades in the future, so if we can forget about feedwordpress, I only have to get your script working outside of the dashboard.

    I guessed it might have been taking some variables from the dashboard. I don’t suppose there’d be an easy way of including them with an

    or something similar at the top of the file?

    I guess what I’m trying to achieve now is to make a version of your plug-in that works outside of the dashboard.

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    Can it send photos via email? If so, I recommend just installing Postie and setting up a blog email account at GMail or something. Then to “blog” a photo you just send the picture to the special email account.

    Works for me.

    If you want to make a page that you can hit to do the image import then you should be able to do something like feedwordpress has done with update-feeds.php. You shouldn’t have to change the plugin at all, you just need to create a page that hits the server in a way that emulates what happens you when you press “Start” from the admin interface.

    I haven’t tried this, and I will when I get some time, but if you look in update_feeds.php you will notice that most of the “feedwordpress” specific content is after the following line…

    $feedwordpress =& new FeedWordPress;

    From what I can tell, everything before that is the setup required to make sure the user is logged in and some nice formating. There might be a simpler example of that sort of thing but that would be a good start for creating a new php file that just ran the Blogger Image Import without going through the admin interface. You should not need to change the importer script at all, just add a new script to execute it.

    Otto, thanks a lot for your suggestion, it works perfectly. Well I have to press a few more buttons on the phone when I want to post, but I don’t mind as it’s a more direct solution. I just didn’t think about doing that instead than trying to work around blogger’s madness.

    Poco, thanks for anytime you spent answering my questions, your script works great, but I think I’m going to just use Postie and bid farewell to Blogger completely, which also means I don’t need to use feedwordpress for this any more, either.

    Problem resolved and no more pulling my hair out. Cheers.

    Well, I’m glad you found a good solution. That Postie plugin looks rather interesting as a way to post images by email. I haven’t found a good image post plugin that I am happy with (I’m using Image Manager) but being able to do a post by email would be way easier. I used to use Picasa to post to Blogger and this might allow me to do the same through Picasa email.

    I may have to give that a try.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Using cron job to run Blogger Image Import’ is closed to new replies.