posts.get

argument keys:

  • site: site to get pages to get comments from, e.g. "my-site"
  • posts: list of IDs of posts/comments to get (max 10 of them)

returns: dictionary of posts/comments. For each post/comment there will be item in the dictionary with pos

  • id: ID of post/comment
  • fullname: fullname of page to which comment belongs
  • reply_to: ID of comment which this post/comment replies to
  • title: title of the post/comment
  • content: post/comment body (wiki syntax)
  • html: post/comment body as HTML
  • created_by: user that posted post/comment
  • created_at: time post/comment was posted
  • replies: number of replies to given post/comment - not yet implemented

This posts.get 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 method setSite with your site. Change the FORUM to your forum page. Change the $posts array to list the post IDs. Replace the all caps USERNAME, API KEY, and SITENAME with values specific to you and your site. Find and list the permanent link to the posts to get.


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
    $siteobj = new WikidotSite($SiteName, $Client);
    $returnarray = array();
 
    echo "<h3>posts.get example</h3></br><hr>";
//change setSite method call to your site
    $siteobj->setSite("SITENAME");
//change to permanent link id of posts to get
    $posts = array("POSTID1", "POSTID2");
    $siteobj->php_posts_get($posts, $returnarray);
    foreach($returnarray as $key=>$data){
        foreach($data as $dkey=>$pdat){
        echo $key.": ".$dkey."=>".$pdat."</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