Export a confluence page for client review (no login required)

Gijs Epping April 5, 2012

Hi,

We had a problem that we wanted our customers to review technical documentation but i didn't want them to have access to the system. The content of page is private so i couldn't put it on a public page.

Currently there is no option to link to a "private" viewing url that has visibilbe without logging in. So i created a simple script that exports a whole page (attachments and all) and put it in a folder.

It is some ugly coding but it works! just fill in your username, password, the space ID and the page title and you can export it.

<?php
$soapClient = new SoapClient(null, array(
"location" => "http://shopworks.atlassian.net/confluence/rpc/soap-axis/confluenceservice-v1?wsdl",
"uri" => "http://soap.rpc.confluence.atlassian.com",
 "trace" => TRUE));

$soapClient = new SoapClient(
    "http://shopworks.atlassian.net/confluence/rpc/soap-axis/confluenceservice-v2?wsdl"
    ,array("trace" => 1, "exceptions" => 0)
);      
$token = $soapClient->login('username', 'password');

$name_document = 'Title of the document';
$name_space = 'TO';

$page = $soapClient->getPage($token,$name_space,$name_document);
$page2 = $soapClient->renderContent($token, $name_space, $page->id);

$attachments = $soapClient->getAttachments($token,$page->id);

foreach($attachments as $attachment){

    $file = file_get_contents((string)$attachment->url.'&os_username=username&os_password=hk37K');
    $dir = "/home/shopworks/www/wiki/download/attachments/".$page->id.'/';
    
    if(!is_dir($dir)){
       mkdir($dir, 0777);
       chmod($dir, 0777);
    }
    
    file_put_contents($dir.$attachment->fileName, $file);
}

function niceName($name){
    $name = str_replace(' ', '_', $name);
    $name = strtolower($name);
    
    return $name;
}

$str =  str_replace('</style>',$style, $page2);
$str = str_replace('</body>',$footer, $str);

$newName = md5(time()).'-'.niceName($name).'.html';


file_put_contents($newName, $str);
chmod($newName, 0777);

echo 'http://www.shopworks.nl/customerpage/'.$newName;
?>

Hope somebody finds it as usefull as me.

Greetings Gijs

http://www.shopworks.nl

2 answers

0 votes
Gijs Epping January 17, 2013

Hi Gary,

Thank you, the format is html. When you use this with other plugins like Balsamiq or Gliffy you will have some problemns viewing.

But this is our latetst version with a nice template:

http://pastebin.com/UEQqNutZ

Greetings Gijs

0 votes
Gary
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 16, 2013

Hi Gijs,

Nice work on this - what format does the page get saved as locally? Our Support Staff will proably link this as a posssible workaround for other users - again, great work.

Cheers,

Gary

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events