files.get_one
This method works for small files only (max 6 MB).
Get file attached to page (alternatively you can use download_url from the files.get_meta method)
argument keys:
- site: site to get the page from
- page: page to get the file from
- file: name of file to get
returns: dictionary with the same keys as files.get_meta and additionally:
- content: base64-encoded file contents
This files.get_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. Change the $PageName variable to the page that contains the file. Change the $filename variable to the file of interest. Replace the all caps USERNAME, API KEY, and SITENAME with values specific to you and your site. File content is sent back as a base64 encoded string.
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 //common example start $fileobj = new FilesWikidotMeta($SiteName, $Client); $returnarray = array(); echo "<h3>files.get_one example</h3></br><hr>"; //change $PageName to the page containing the file $PageName = "CATEGORY:PAGENAME"; $fileobj->setPage($PageName); //change the $filename to the file of interest $filename = "FILENAME.EXT"; $fileobj->php_files_get_one($filename, $returnarray); foreach ($returnarray as $key=>$file){ echo $key."=>".$file."</br>";}
Download Code File
Live demo
Uses above code in an Iframe from a PHP host.
page revision: 14, last edited: 05 Sep 2012 18:11