-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglpiws_example.php
86 lines (73 loc) · 2.17 KB
/
glpiws_example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* GLPI WebService Integration
*
* @author diego.pessanha
* @since 2014-10-09
*
* Utiliza a classe GlpiWebService para integrar com o glpi via soap
*/
error_reporting(E_ALL);
ini_set('display_errors', 1);
include_once dirname(__FILE__) . "/glpiws.class.php";
echo "\n*** GLPI SOAP Integration ***\n\n";
######################
# GLPI Integration #
######################
// Init GLPI integration class
$GlpiWebService = new GlpiWebService();
$GlpiWebService->url = "http://www.yourglpi.com/plugins/webservices/soap.php";
$GlpiWebService->ws_user = 'web_srv_usr'; // OPTIONAL Web service user
$GlpiWebService->ws_pass = ''; //OPTIONAL
$GlpiWebService->glpi_user = 'glpi_user'; // GLPI user
$GlpiWebService->glpi_pass = 'glpi_user_pwd';
// Connect and automatically login
if (!$GlpiWebService->connect())
{
echo $GlpiWebService->getErrors() . "\n\n";
exit(1);
}
// Ticket information
$ticket = array(
'content' => "Description",
'status' => 1, // Progress
'type' => 1, // Incident
'urgency' => 2, // Low
'impact' => 2, // Low
'category' => 155, // Category
'item' => 534, // Item ID
'itemtype' => 'Computer', // item type
'title' => "Ticket Title (Example)",
'source' => 'WebServices',
'date' => '2014-11-10 01:12:30'
);
$user = 22; // Usuário a quem foi atribuido o chamado
$group = null; // Grupo a quem foi atribuido o chamado
$solutionType = 3;
$closeMessage = $solutionMessage = "Executado sem falhas";
// Create the ticket and set the solution
if (!$id = $GlpiWebService->createTicket($ticket, $user, $group))
{
echo $GlpiWebService->getErrors() . "\n\n";
exit(1);
}
// Upload a file
if (!$GlpiWebService->uploadDocument($id, "nome_documento.jpg", "/home/diego/Pictures/Jedi_Logo.jpg"))
{
echo $GlpiWebService->getErrors() . "\n\n";
exit(1);
}
// Set the solution
if (!$GlpiWebService->resolveTicket($id, $solutionType, $solutionMessage))
{
echo $GlpiWebService->getErrors() . "\n\n";
exit(1);
}
// Close the ticket
if (!$GlpiWebService->closeTicket($id, $closeMessage))
{
echo $GlpiWebService->getErrors() . "\n\n";
exit(1);
}
echo "Ticket $id created successfuly!\n\n";
exit(0);//Success