2017 © Pedro Peláez
 

library confluence-rest-api

Confluence REST API Client for PHP Users.

image

lesstif/confluence-rest-api

Confluence REST API Client for PHP Users.

  • Sunday, April 29, 2018
  • by lesstif
  • Repository
  • 1 Watchers
  • 5 Stars
  • 1,145 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 1 Open issues
  • 6 Versions
  • 16 % Grown

The README.md

PHP Confluence Rest Client

Atlassian's Confluence & Confluence Question REST API Client for PHP Users., (*1)

installation

  1. Install PHP Composer manually or download it from composer home page., (*2)

    sh php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php composer-setup.php php -r "unlink('composer-setup.php');", (*3)

  2. run composer for install dependency., (*4)

    php composer.phar require 'lesstif/confluence-rest-api'
    

or update your composer.json., (*5)

"require": {
    "lesstif/confluence-rest-api": "^0.1"
}

Configuration

you can choose loads environment variables either 'dotenv' or 'array'., (*6)

use dotenv

copy .env.example file to .env on your project root directory., (*7)

CONFLUENCE_HOST="https://your-confluence.host.com"
CONFLUENCE_USER="confluence-username"
CONFLUENCE_PASS="confluence-password"

use array

create Service class with ArrayConfiguration parameter., (*8)

use Lesstif\Confluence\Question\QuestionService;

$qs = new QuestionService(new \Lesstif\Confluence\Configuration\ArrayConfiguration(
          [
              'host' => 'https://your-confluence.host.com',
              'user' => 'confluence-username',
              'password' => 'confluence-password',
          ]
   ));

Usage

CQL

$cql = [
    'SPACE' => 'LAR',
    'type' => 'page',
    ];

try {
    $s = new CQLService();

    $ret = $s->search($cql);

    dump($ret);

} catch (\Lesstif\Confluence\ConfluenceException $e) {
    $this->assertTrue(false, 'testSearch Failed : '.$e->getMessage());
}

Question

getting Question list


$queryParam = [ // the number of questions needed (10 by default) 'limit' => 10, //the start index (0 by default) 'start' => 0, // The optional filter string which value is one of "unanswered", "popular", "my", "recent" // (default value 'recent') 'filter' => 'unanswered', ]; try { $qs = new QuestionService(); $questions = $qs->getQuestion($queryParam); foreach($questions as $q) { echo sprintf("<a href=\"%s\">%s</a><p/>\n", $q->url, $q->title); } } catch (\Lesstif\Confluence\ConfluenceException $e) { $this->assertTrue(false, 'testSearch Failed : '.$e->getMessage()); }

getting Question's detail info.

try {
    $qs = new QuestionService();

    $q = $qs->getQuestionDetail($questionId);

    foreach($q->answers as $a)
    {
        // print accepted answer
        if ($a->accepted === true) {
            dump($a);
        }
    }

} catch (\Lesstif\Confluence\ConfluenceException $e) {
    $this->assertTrue(false, 'testSearch Failed : '.$e->getMessage());
}

getting accepted answer

try {
    $qs = new QuestionService();

    $q = $qs->getAcceptedAnswer($questionId);
    dump($q);

} catch (\Lesstif\Confluence\ConfluenceException $e) {
    $this->assertTrue(false, 'testSearch Failed : '.$e->getMessage());
}

Answer

getting user's answer list

try {
    $username = 'lesstif';

    $as = new AnswerService();

    $ans = $as->getAnswers($username);

    foreach($ans as $a) {
        dump($a);
    }

} catch (\Lesstif\Confluence\ConfluenceException $e) {
    $this->assertTrue(false, 'testSearch Failed : '.$e->getMessage());
}
try {
    $answerId = '123456';

    $as = new AnswerService();

    $q = $as->getQuestion($answerId);

    dump($q);
} catch (\Lesstif\Confluence\ConfluenceException $e) {
    $this->assertTrue(false, 'testSearch Failed : '.$e->getMessage());
}

Confluence Rest API Documents

  • Confluence Server REST API - https://developer.atlassian.com/confdev/confluence-server-rest-api
  • latest server - https://docs.atlassian.com/atlassian-confluence/REST/latest-server/
  • Confluence Question REST API - https://docs.atlassian.com/confluence-questions/rest/index.html

The Versions

29/04 2018

dev-master

9999999-dev

Confluence REST API Client for PHP Users.

  Sources   Download

Apache-2.0 Apache 2.0

The Requires

 

The Development Requires

rest confluence confluence-php confluence-rest

20/02 2018

dev-develop

dev-develop

Confluence REST API Client for PHP Users.

  Sources   Download

Apache-2.0 Apache 2.0

The Requires

 

The Development Requires

rest confluence confluence-php confluence-rest

09/06 2017

dev-feature/wiki_download

dev-feature/wiki_download

Confluence REST API Client for PHP Users.

  Sources   Download

Apache 2.0

The Requires

 

The Development Requires

rest confluence confluence-php confluence-rest

11/01 2017

0.2

0.2.0.0

Confluence REST API Client for PHP Users.

  Sources   Download

Apache 2.0

The Requires

 

The Development Requires

rest confluence confluence-php confluence-rest

10/01 2017

0.1.1

0.1.1.0

Confluence REST API Client for PHP Users.

  Sources   Download

Apache 2.0

The Requires

 

The Development Requires

rest confluence confluence-php confluence-rest

10/01 2017

0.1

0.1.0.0

Confluence REST API Client for PHP Users.

  Sources   Download

Apache 2.0

The Requires

 

The Development Requires

rest confluence confluence-php confluence-rest