Integrating Confluence in to our website
Asked by oliver marshall:

Hi

We're looking at using Confluence for an internal and external knowledgebase. A number of our suppliers use it, so we're happy it does what we want.

However we want our customers to find common wiki entries via our website, where we send them for various bits of info at the moment.

Other KB/Wiki tools we've looked at provide a javascript widget we can include in the site which will give us a CSS'able search box and results. That works nicely.

At a push I'd take the ability to use an iframe on our site pointing to a basic page with no confluence navbars or headers (just the page and search bar).

Anyone got any comments or feedback at all on this? Our site is in Wordpress if that helps.

Olly


Answers:
author: Daniel Borcherding
body: Olly,

I had previouly filed a similar feature request. Please take a moment to see if that will work for your needs. Please feel free to add any comments about functionality you see that is missing from the request.

<https://jira.atlassian.com/browse/CONF-26832>

I also wanted to direct your attention to our end user agreement.

<http://www.atlassian.com/end-user-agreement/>

It states that at mimimum your confluence instnace must contain the text "Powered By Atlassian" in the footer of your page. Please be sure to keep this in mind when you are developing this custom solution.


author: David at David Simpson Apps
body: Look at how the quick search drop down is populated in the Confluence search box - it delivers JSON to build the drop down menu.

Use a similar approach to query that same URL for your Wordpress search integration. You can use Firebug or Google Chrome developer tools to watch the network requests.

This approach means that you're just querying the available APIs - you won't have to add the "Powered by..." text.

**Update:**

This scrappy bit of *working* PHP code will add Confluence search results to a PHP page:

```
&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;	&lt;title&gt;Search&lt;/title&gt;&lt;/head&gt;&lt;body&gt;	&lt;h1&gt;Search Atlassian's documentation&lt;/h1&gt;	&lt;form&gt;		&lt;input name="q" placeholder="Search Confluence..."&gt;		&lt;input type="submit"&gt;	&lt;/form&gt;&lt;?php if (isset($_GET['q'])) {			$query = rawurlencode( $_GET['q']);		$timestamp = time();		$baseUrl = 'http://confluence.atlassian.com';		$url = $baseUrl.'/json/contentnamesearch.action?query='.$query.'&amp;_='.$timestamp;		$response = file_get_contents($url);		$response = json_decode($response);				$results = $response-&gt;contentNameMatches[0];?&gt;			&lt;h2&gt;Results&lt;/h2&gt;	&lt;div&gt;Searching: &lt;?php echo $url; ?&gt;		&lt;h3&gt;Formatted&lt;/h3&gt;	&lt;ol&gt;	&lt;?php foreach($results as $item) {?&gt;			&lt;li&gt;&lt;strong&gt;&lt;a href="&lt;?= $baseUrl. $item-&gt;href ?&gt;"&gt;&lt;?= $item-&gt;name ?&gt;&lt;/a&gt;&lt;/strong&gt; in &lt;a href="&lt;?= $baseUrl.'/display/'.$item-&gt;spaceKey ?&gt;"&gt;&lt;?= $item-&gt;spaceName ?&gt;&lt;/a&gt;&lt;/li&gt;	&lt;?php } ?&gt;	&lt;/ol&gt;	&lt;h3&gt;Raw JSON&lt;/h3&gt;	&lt;pre&gt;		&lt;?php print_r($response); ?&gt;	&lt;/pre&gt;&lt;?php } ?&gt;&lt;/body&gt;&lt;/html&gt;
```

Clean it up with some error handling though. Also, take a look at the source code of **contentnamesearch.action** to get it to return more than 6 results ;)


author: oliver marshall
body: So, as they are saying no it's an iframe then? Is that right? Anyone know of a 3rd party widget which will allow searching from our site? Olly


Tags: cloud

confluence-cloud

integration

javascript

wordpress