pages.save_one

Save page. Site and page keys of argument array are required. Set specific keys to update the properties, omit to keep current values.
argument keys:

  • site: site to save page to
  • page: page full name to save
  • title (optional): title to set
  • content (optional): page content — wiki source
  • tags (optional): array of tags to set
  • parent_fullname (optional): parent page full name, "-" to reset
  • save_mode (optional): allowed mode of operation
    • create: only allow creating new objects (exception thrown if object with this name already exists)
    • update: only allow updating objects (exception thrown if no object with this name exists)
    • create_or_update (default): allow both creating and updating object
  • rename_as (optional): rename the page (in addition to possible other changes in source etc)
  • revision_comment (optional): revision comment (displayed in history)
  • notify_watchers (optional):
    • true: notify watchers about the edit (as if it was done with the web interface)
    • false (default): don't notify watchers

returns: saved page (as in page.get_one)

This pages.save_one demo uses the sample code below. Create a separate file in your hosted site. Change the path to the wikidot_class.inc and xmlrpc.inc files. Call the methods setPage, setTags, setParentFullname, setTitle, and setContent for the new file to save. Replace the all caps USERNAME, API KEY, and SITENAME with values specific to you and your site.


Sample Code

<?php
//set globals before includes
    $newdebuglevel = 0;    
 
//add includes
//change path to your server location
    include("../classes/wikidot_class.inc");
 
//set startup parameters for xmlrpc
//change path to your server location
    require_once("../classes/xmlrpc.inc");
    $GLOBALS ['xmlrpc_null_extension' ] = true;
    $ServerPath = "xml-rpc-api.php";
    $ServerHostName = "www.wikidot.com";
    $ServerPort = "";
 
//create a client for your site
 
    $Client = new xmlrpc_client($ServerPath,$ServerHostName,$ServerPort);
    $Client->setCredentials("USERNAME","API KEY");
    $Client->setDebug($newdebuglevel);
    $Client->setSSLVerifyPeer(false);
    $Client->setSSLVerifyHost(false);
    $Client->return_type = "phpvals"; //forces return of page.get_one as php values
    $SiteName = "SITENAME";
 
////////////test code
////////////code doesn't include error checking
    $pageobj = new WikidotPage($SiteName, $Client);
    $returnarray = array();
    echo "<h3>pages.save_one example</h3></br><hr>";
    $savepage = "CATEGORY:NEWPAGENAME";
    $savepagetitle = "New Test Page";
    $tags = array("Tom", "Dick", "Harry");
    $pageobj->setPage($savepage);
    $pageobj->setTags($tags);
    $pageobj->setParentFullname("CATEGORY:PARENT"); //optional
    $pageobj->setTitle($savepagetitle);
    $pageobj->setContent("New page stuff\nSecond line of stuff");
    if($pageobj->php_pages_save_one("create_or_update")){
        echo "Success</br>";}
?>

Download Code File

Live demo

Uses above code in an Iframe from a PHP host.


Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License