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

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
Gary Sackett Atlassian Team Jan 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

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 12, 2019 in Confluence

Confluence Admin Certification now $150 for Community Members

More and more people are building their careers with Atlassian, and we want you to be at the front of this wave! Important Dates Start the Certification Prep Course by 2 April 2019 Take your e...

1,479 views 4 13
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you