pages.get_one
argument keys:
- site: site to get a page from, e.g. "my-site"
- page: page full name to get, e.g. "start" or "blog:first-post"
returns: page properties as dictionary (consult documentation of ListPages module) all those listed in pages.get_meta plus:
- parent_title
- children
- content: page content, if page is assigned a form it's in YAML format
- html: generated HTML of the page (as seen from browser excluding navigational bars etc)
- comments: number of comments
- commented_at
- commented_by
This pages.get_one demo uses the sample code below. Create a separate file in your hosted site. Call the setPage method with the page name to get. Change the path to the wikidot_class.inc and xmlrpc.inc files. Replace the all caps USERNAME, API KEY, and SITENAME with values specific to you and your site.
Sample Code
//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.get_one example</h3></br><hr>"; $pageobj->setPage("CATEGORY:EXISTINGPAGE"); if($pageobj->php_pages_get_one($returnarray)){ echo "Success</br>"; echo "</br>"; $tagarray = $returnarray[tags]; echo "Fullname: ".$returnarray[fullname]."</br>". "Created At: ".$returnarray[created_at]."</br>". "Created By: ".$returnarray[created_by]."</br>". "Updated At: ".$returnarray[updated_at]."</br>". "Updated By: ".$returnarray[updated_by]."</br>". "Title: ".$returnarray[title]."</br>". "Parent Fullname: ".$returnarray[parent_fullname]."</br>". "Rating: ".$returnarray[rating]."</br>". "Revisions: ".$returnarray[revisions]."</br>". "Page Title: ".$returnarray[parent_title]."</br>". "Children: ".$returnarray[children]."</br>". "Content: ".$returnarray[content]."</br>". "Comments: ".$returnarray[comments]."</br>". "Commented At: ".$returnarray[commented_at]."</br>". "Commented By: ".$returnarray[commented_by]."</br>"; foreach($tagarray as $key=>$tagdata){ echo "Tag ".$key." : ".$tagdata."</br>";} echo "<hr>Page HTML Below<hr></br>".$returnarray[html]."</br><hr>";}
Download Code File
Live demo
Uses above code in an Iframe from a PHP host.
page revision: 5, last edited: 05 Sep 2012 18:14