files.get_meta
Get meta data of given files
argument keys:
- site: what site we ask about
- page: what page (full name) we ask about
- files: name of files to get meta data of — max 10 of them
returns: dictionary of files. File name is key of each item in it. The value is a dictionary of:
- size: size in bytes
- comment
- mime_type
- mime_description
- uploaded_by
- uploaded_at
- /download_url: URL to download the file from. For private sites, the URL contains authorization token ?ukey=… valid for about 5 minutes.
This files.get_meta demo uses the sample code below. Create a separate file in your hosted site. Change the $PageName variable to the page that contains the files. Change the $Filearray array to list the file names of interest. 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 //common example start $fileobj = new FilesWikidotMeta($SiteName, $Client); $returnarray = array(); echo "<h3>files.get_meta example</h3></br><hr>"; //change $PageName to the page that contains the files you want information $PageName = "CATEGORY:PAGENAME"; $fileobj->setPage($PageName); //add file names to the $Filearray array to match the files of interest $Filearray = array( "FILE1.EXT", "FILE2.EXT", "FILE2.EXT", etc...); $fileobj->php_files_get_meta($Filearray, $returnarray); foreach ($returnarray as $key=>$file){ foreach($file as $dkey=>$fdat){ echo $key.": ".$dkey."=>".$fdat."</br>";}}
Download Code File
Live Demo
Uses above code in an Iframe from a PHP host.
page revision: 13, last edited: 05 Sep 2012 18:08