Beispiel #1
0
<?php

/** 
 * This is an example.
 * Here you can learn how to create a new user.
 * 
 * @author José A. Muriano <*****@*****.**>
 * 
 */
require_once '../vendor/autoload.php';
use PHPRedmineAPI\RedmineAPI;
$api = new RedmineAPI('https://185.8.244.222', 'xml', true);
$api->setAuthenticationByAPIKey('f7ff7db66117124dbdb317710638363dc5b236b5');
$newUser = $api->createUser('1234567892', 'ertablas', 'Foo', 'Bar', '*****@*****.**');
echo '<pre>';
print_r($newUser);
echo '</pre>';
<?php

/** 
 * This is an example.
 * Here you can learn how to create a new contact.
 * 
 * @author José A. Muriano <*****@*****.**>
 * 
 */
require_once '../vendor/autoload.php';
use PHPRedmineAPI\RedmineAPI;
$api = new RedmineAPI('https://185.8.244.222', 'xml', true);
$api->setAuthenticationByAPIKey('f7ff7db66117124dbdb317710638363dc5b236b5');
$projectId = 'crm';
$firstName = 'José Antonio';
$parameters = ['company' => 'Telcom BS', 'email' => '*****@*****.**', 'last_name' => 'Muriano Criado', 'job_title' => 'CEO', 'tag_list' => 'vPBX, Línea SIP, SIP Trunking, Envío SMS, vDrive, vDesktop', 'visibility' => '0'];
try {
    $contact = $api->createContact($projectId, $firstName, $parameters);
} catch (\PHPRedmineAPI\exceptions\ErrorResponseException $e) {
    echo "<pre>";
    echo $e->getRequestBody() . PHP_EOL;
    echo $e->getRequestMethod() . PHP_EOL;
    echo $e->getRequestUri() . PHP_EOL;
    echo $e->getResponseHeaders() . PHP_EOL;
    echo "</pre>";
}
$customFields = ['@type' => 'array', 'custom_field' => [['id' => 3, 'value' => '0000000001'], ['id' => 4, 'value' => 1462]]];
$contact->set('custom_fields', $customFields)->save();
var_dump($contact);
<?php

require_once '../vendor/autoload.php';
use PHPRedmineAPI\RedmineAPI;
$api = new RedmineAPI('https://185.8.244.222', 'xml', true);
$aUsers = $api->getUsers('all', ['group_id' => 28], [], 0, 2000);
$numRows = count($aUsers);
foreach ($aUsers as $user) {
    echo $user->id . '<br/>' . PHP_EOL;
    $user->destroy();
}
echo '<hr>';
echo 'Número de registros afectados: ' . $numRows;
Beispiel #4
0
<?php

/**
 * This is an example.
 * Here you can check how to get a full list of issues registered in your system.
 * 
 * @author José A. Muriano  <*****@*****.**>
 * 
 */
require_once '../vendor/autoload.php';
use PHPRedmineAPI\RedmineAPI;
$api = new RedmineAPI('https://185.8.244.222', 'xml', true);
$issues = $api->getIssues();
foreach ($issues as $thisIssue) {
    echo $thisIssue->subject;
    echo '<br>' . PHP_EOL;
}
Beispiel #5
0
<?php

/** 
 * This is an example.
 * Here you can learn how to delete a user.
 * 
 * @author  Jose A. Muriano <*****@*****.**>
 */
require_once '../vendor/autoload.php';
// First, create a user:
use PHPRedmineAPI\RedmineAPI;
$api = new RedmineAPI('https://185.8.244.222', 'xml', true);
$newUser = $api->createUser('0000000001', 'ertablas', 'User to be delete', 'this does not matter so much', '*****@*****.**', 1);
$userId = $newUser->id;
// Then select user by its id, and call to destroy method.
$user = $api->getUsers($userId);
$user->destroy();
<?php

/** 
 * This is an example.
 * Here you can learn how to get a contact by using a custom field.
 * 
 * @author José A. Muriano <*****@*****.**>
 * 
 */
require_once '../vendor/autoload.php';
use PHPRedmineAPI\RedmineAPI;
/**
 * @var RedmineAPI 
 */
$api = new RedmineAPI('https://185.8.244.222', 'xml', true);
$api->setAuthenticationByAPIKey('f7ff7db66117124dbdb317710638363dc5b236b5');
$contact = $api->getContacts('all', ['cf_4' => 1462]);
var_dump($contact);
<?php

/**
 * This is an example.
 * Here you can learn how to create a new contact.
 *
 * @author José A. Muriano <*****@*****.**>
 *
 */
require_once '../vendor/autoload.php';
use PHPRedmineAPI\RedmineAPI;
$api = new RedmineAPI('https://185.8.244.222', 'xml', true);
$api->setAuthenticationByAPIKey('f7ff7db66117124dbdb317710638363dc5b236b5');
$issue = ['project_id' => 'crm', 'tracker_id' => 1, 'description' => 'This is a ticket created from API', 'subject' => 'API Ticket'];
$contact = ['email' => '*****@*****.**', 'first_name' => 'John', 'last_name' => 'Doe', 'tag_list' => 'Autocreado, Servicio 1, Servicio 2, Servicio 3, Main,'];
$contact = ['id' => 18756];
try {
    $ticket = $api->createHelpdeskTicket($issue, $contact);
} catch (\PHPRedmineAPI\exceptions\ErrorResponseException $e) {
    echo "<pre>";
    echo $e->getRequestBody() . PHP_EOL;
    echo $e->getRequestMethod() . PHP_EOL;
    echo $e->getRequestUri() . PHP_EOL;
    echo $e->getResponseHeaders() . PHP_EOL;
    echo "</pre>";
}
var_dump($ticket);
Beispiel #8
0
<?php

/**
 * This is an example.
 * Here you can check how to get a full list of issues registered in your system.
 *
 * @author José A. Muriano  <*****@*****.**>
 *
 */
require_once '../vendor/autoload.php';
use PHPRedmineAPI\RedmineAPI;
/** @var $api \PHPRedmineAPI\RedmineAPI */
$api = new RedmineAPI('https://185.8.244.222', 'xml', true);
$api->setAuthenticationByAPIKey('f7ff7db66117124dbdb317710638363dc5b236b5');
/* @var $result string */
$result = $api->uploadFile('/var/log/apache2/error.log');
echo PHP_EOL . $result . PHP_EOL;
Beispiel #9
0
<?php

/**
 * This is an example.
 * Here you can see how to get a full list of projects and get their sub-categories.
 * 
 * @author José A. Muriano <*****@*****.**>
 * 
 */
require_once '../vendor/autoload.php';
use PHPRedmineAPI\RedmineAPI;
$api = new RedmineAPI('https://185.8.244.222', 'xml', true);
$id = isset($_GET['id']) && trim($_GET['id']) ? $_GET['id'] : 'all';
$projects = $api->getProjects($id, ['include' => 'issue_categories']);
if ($id == 'all') {
    foreach ($projects as $thisProject) {
        echo "<a href=\"?id={$thisProject->identifier}\">{$thisProject->name}</a><br>";
    }
} else {
    ?>
  <div>
      <b>Categoría</b>: <?php 
    echo $projects->name;
    ?>
<br/>
      <b>Idenfiticador</b>: <?php 
    echo $projects->identifier;
    ?>
<br/>
      <b>Descripción</b>: <?php 
    echo $projects->description;