The MU forums have moved to

How to make an API (6 posts)

  1. Vimm
    Posted 16 years ago #

    I would like to make a simple API for MU-Wordpress for my own use but I'm not having much luck. I've made some plugins and have been quite pleased with how easy and intuitive it has been to figure out Wordpress, however if I use that same exact code in a non-plugin it refuses to work.

    I've noticed that in order for my API to run and not get re-directed to the registration page I need to add the following:

    define("WP_INSTALLING", true);

    However, when I add that code lots of MU functions that I need stop working. Things like switch_to_blog() and add_user_to_blog(), and lots of other functions I need. There are no errors, they simply do nothing when called. I've been getting around this by tracing the functions and copying the exact SQL queries I need, but why re-invent the wheel? Surely someone has tried this before, so isn't there a simple way I can make an API for MU-WordPress? Could someone point me to an example?

  2. mysorehead
    Posted 16 years ago #

    You can add methods to xml_rpc API by using the xmlrpc_methods filter. That is the way I'd it.

    Using xml_rpc methods quite easily access your existing working plugin functions. Just use an You still need to authenticated and I cannot see any reason to do what you are after.

    Note: I haven't tried this, although I have written a vbscript to publish static html pages created with an educational program called clicker 4. I can probably dig up that code if you want.


    If you don;t want to go this route it may be worth looking at the xml_rpc file and see if the code is including any scripts that you are not.

  3. Vimm
    Posted 16 years ago #

    I need a custom API because I need to import several hundred blogs from blogging software for which no migration exists (blojsom 3.0). The simplest way I see to do it is to create a simple API that I can feed an entire blog's data to, then simply repeat the process for each blog. It would be much easier if I can simply tap into already existing code. It seems like that would be easier than hacking up both an RSS export and RSS import feature.

    I'll take a look at xmlrpc_methods. Perhaps I can use that for my app integration once the migration's complete.

  4. lunabyte
    Posted 16 years ago #

    It really wouldn't need to be so complicated.

    As long as the databases are side by side, you would grab data from 1 db, and migrate it to another.

    Basically, just an import and convert script.

    Do they not have RSS feeds? There is an import for that.

  5. drmiketemp
    Posted 16 years ago #

    I was thinking of luna's idea as well if blojsom's db was MySQL. (I can't find details on their site and I've got to go play volunteer anyway)

  6. Vimm
    Posted 16 years ago #

    Blojsom does use MySQL but it lumps all blogs into one giant table rather than separate tables for each blog like MU-Wordpress does. In order to migrate I need to:

    A. Create each blog
    B. Transfer users and permissions
    C. Migrate content

    I really don't see how an RSS feed can accomplish all three. There are also many incompatibilities where data that's valid in Blojsom is invalid in Wordpress. I've already finished A and gotten partway through B, but without the use of functions like switch_to_blog() it's slow going having to track down all the SQL. Perhaps I can use an RSS export/import for part C, otherwise that part will take a while if I have to go from database to database the whole way.

About this Topic