<?php

use Adlogix\ConfluenceClient\ClientBuilder;
use Adlogix\ConfluenceClient\Security\QueryParamAuthentication;
use Adlogix\ConfluenceClient\Tests\Helper\Payload;
require_once 'vendor/autoload.php';
/**
 * See the 'installed' webhook on how to recover this payload.
 *
 * The sharedSecret is given by the application we installed the add-on to,
 * this is needed to sign our request and to validate the requests from the application.
 */
$payload = new Payload('payload.json');
$authenticationMethod = new QueryParamAuthentication('eu.adlogix.confluence-client', $payload->getSharedSecret());
/** @var \Adlogix\ConfluenceClient\Client $client */
$client = ClientBuilder::create($payload->getBaseUrl(), $authenticationMethod)->setDebug(true)->build();
$response = $client->sendRawApiRequest('GET', 'space');
echo $response->getBody()->getContents();
echo "\r\n\r\n=======================================================================================================" . "==============================================================================================\r\n\r\n";
$response = $client->downloadAttachment('download/attachments/197288/Seller%20Admin%20logo%20stats.png?api=v2');
echo $response->getBody()->getContents();
Ejemplo n.º 2
0
use Adlogix\ConfluenceClient\ClientBuilder;
use Adlogix\ConfluenceClient\Entity\Descriptor;
use Adlogix\ConfluenceClient\Security\QueryParamAuthentication;
use Adlogix\ConfluenceClient\Tests\Helper\Payload;
use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
require_once 'vendor/autoload.php';
/**
 * See the 'installed' webhook on how to recover this payload.
 *
 * The sharedSecret is given by the application we installed the add-on to,
 * this is needed to sign our request and to validate the requests from the application.
 */
$payload = new Payload('payload.json');
$applicationKey = 'eu.adlogix.confluence-client';
$authenticationMethod = new QueryParamAuthentication($applicationKey, $payload->getSharedSecret());
$client = ClientBuilder::create($payload->getBaseUrl(), $authenticationMethod)->build();
/**
 * Since Confluence needs to reach our application to post some information, like the sharedSecret, we have to define some routes.
 * At time of writing Confluence refuses to contact us if the route contains .php so we need to prettify our URLS.
 * Our sample is not the best way to do it, but it's just for the demo.
 */
$app = new Application();
$app['debug'] = true;
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/views'));
/**
 * Our sample descriptor is available at http://confluence-client.dev/descriptor.json
 *
 * This is the bare minimal descriptor to be defined.