-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathexample.php
112 lines (95 loc) · 2.28 KB
/
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
/**
Alternatively use [composer](http://getcomposer.org/) and just:
require 'vendor/autoload.php'
*/
require_once 'RequestTracker.php';
$url = "http://rt.easter-eggs.org/demos/4.2/";
$user = "admin";
$pass = "admin";
$rt = new RequestTracker($url, $user, $pass);
//Get the properties of an existing ticket, given the ID
/*
$response = $rt->getTicketProperties(158);
print_r($response);*/
//Create a new ticket- see http://requesttracker.wikia.com/wiki/REST#Ticket_Create for all fields
/*
$content = array(
'Queue'=>'fast_lane',
'Requestor'=>'[email protected]',
'Subject'=>'Lorem Ipsum',
'Text'=>'dolor sit amet'
);
$response = $rt->createTicket($content);
print_r($response);
*/
//Edit a ticket
/*
$content = array(
'Priority'=>3
);
$response = $rt->editTicket(233, $content);
print_r($response);
*/
//Reply to a ticket
/*
$content = array(
'Text'=>'This is a test reply.'
);
$response = $rt->doTicketReply(233, $content);
print_r($response);
*/
//Comment on a ticket
/*
$content = array(
'Text'=>"This is a test comment.\nNew Line"
);
$response = $rt->doTicketComment(168, $content);
print_r($response);
*/
//Ticket Links
/*
$content = array(
'DependsOn'=>1
);
$response = $rt->editTicketLinks(233, $content);
print_r($response); */
/*
$response = $rt->getTicketLinks(233);
print_r($response); */
//Attachment management
/*
$response = $rt->getTicketAttachments(3);
print_r($response);
$response = $rt->getAttachment(3, 13);
print_r($response);
$response = $rt->getAttachmentContent(3, 13);
print_r($response);
*/
// Adding attachment when replying. (Untested)
/*
// PHP > 5.5
$attachments = [
'2.txt' => new \CURLFile('/tmp/phpK5TNJc', 'text/plain', '2.txt'),
];
// PHP < 5.5
$attachments = array(
'2.txt' => '@/tmp/phpK5TNJc;type=text/plain;filename=2.txt',
);
$content = array(
'Text' => 'This is a test reply.',
);
$rt->doTicketReply(233, $content, $attachments);
*/
//Ticket History
/*
$response = $rt->getTicketHistory(233);
print_r($response);
$response = $rt->getTicketHistoryNode(233,3702);
print_r($response);
*/
//Search demonstration
//Unowned tickets ordered by Created date descending
/*
$response = $rt->search("Owner='Nobody'",'-Created', 's');
print_r($response); */