The MU forums have moved to WordPress.org

implementing a web service API (6 posts)

  1. fleshins
    Member
    Posted 14 years ago #

    I'm interested in writing a web service API for wpmu that does something simple e.g. manage user subscriptions to blog post notifications (subscribe, unsubscribe, etc.). The idea is to have AJAX make these calls to the web service.

    Can anyone provide some guidance on how to best implement something like this? I was looking at Zend and WSO2 frameworks but not sure if I'm heading in the right direction there.

    So far what I have is a mu-plugin in the form of a class with functions that perform the actions in question (subscribe, unsubscribe, etc.).

    What's the right away for me to expose these functions as a web service? Not sure if I'm even thinking about all of this the right way.

    Thanks for the help in advance.

  2. fleshins
    Member
    Posted 14 years ago #

    So it looks like all I have to do is make sure the web service call hits a php file that loads the WP environment like so:

    require( dirname(__FILE__) . '/wp-load.php' );

    Once that's done, I have access to all the WP functions and the world becomes my little oyster.

  3. SteveAtty
    Member
    Posted 14 years ago #

    My php file (which sits at the root of my domain) starts:

    <?php
    require( dirname(__FILE__) . '/wp-config.php' );
    nocache_headers();

    It returns a data structure (a row per line) which is then manipulated by a different website.

    Be warned, if you've got Supercache installed then you'll need to put the file name into the excluded list or each call will return a line about the file not being cached properly.

  4. fleshins
    Member
    Posted 14 years ago #

    Sorry - I'm having a hard time following - what returns a data structure and how does a different website manipulate it? Is your php file returning some kind of data structure? Is the website you're referring to located on the same host as the php file in question or is this website making a remote call to the php file?

    Thanks for clarifying.

  5. SteveAtty
    Member
    Posted 14 years ago #

    The code further down the file returns the data needed by the other site.

    So they simply call a url and pass it parameters and it returns data.

  6. fleshins
    Member
    Posted 14 years ago #

    Perfect, makes sense :)

About this Topic

  • Started 14 years ago by fleshins
  • Latest reply from fleshins