Guest User

Untitled

a guest
Aug 16th, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.85 KB | None | 0 0
  1. <?PHP
  2. error_reporting(E_ALL);
  3.  
  4. # Please define the connection information here:
  5. $url = "";
  6. $username = "";
  7. $password = "";
  8. $title = "My Test Ticket via SOAP and PHP";
  9. $from = "me@example.com";
  10.  
  11.  
  12. # Set up a new SOAP connection:
  13. $client = new SoapClient(null, array('location' =>
  14. $url,
  15. 'uri' => "Core",
  16. 'trace' => 1,
  17. 'login' => $username,
  18. 'password' => $password,
  19. 'style' => SOAP_RPC,
  20. 'use' => SOAP_ENCODED));
  21.  
  22. # Create a new ticket. The function returns the Ticket ID.
  23. $ticket_parent = $client->__soapCall("Dispatch", array($username, $password,
  24. "TicketObject", "TicketCreate",
  25. "Title", "Nouvel arrivant : M.Dupont",
  26. "Queue", "SI",
  27. "Lock", "Unlock",
  28. "PriorityID", 2,
  29. "State", "new",
  30. "CustomerUser", $from,
  31. "OwnerID", 1,
  32. "UserID", 1,
  33. ));
  34.  
  35. $ticket_enfant1 = $client->__soapCall("Dispatch", array($username, $password,
  36. "TicketObject", "TicketCreate",
  37. "Title", "Ouverture du compte de M.Dupont",
  38. "Queue", "SI::Droits et accès",
  39. "Lock", "Unlock",
  40. "PriorityID", 2,
  41. "State", "new",
  42. "CustomerUser", $from,
  43. "OwnerID", 1,
  44. "UserID", 1,
  45. ));
  46.  
  47. $ticket_enfant2 = $client->__soapCall("Dispatch", array($username, $password,
  48. "TicketObject", "TicketCreate",
  49. "Title", "Création du compte blabla de M.Dupont",
  50. "Queue", "SI::Applications métier",
  51. "Lock", "Unlock",
  52. "PriorityID", 2,
  53. "State", "new",
  54. "CustomerUser", $from,
  55. "OwnerID", 1,
  56. "UserID", 1,
  57. ));
  58.  
  59.  
  60.  
  61. # A ticket is not usefull without at least one article. The function
  62. # returns an Article ID.
  63. $client->__soapCall("Dispatch",
  64. array($username, $password,
  65. "TicketObject", "ArticleCreate",
  66. "TicketID", $ticket_parent,
  67. "ArticleType", "webrequest",
  68. "SenderType", "customer",
  69. "HistoryType", "WebRequestCustomer",
  70. "HistoryComment", "created from PHP",
  71. "From", $from,
  72. "Subject", $title,
  73. "ContentType", "text/plain; charset=ISO-8859-1",
  74. "Body", "Demande de déménagement",
  75. "UserID", 1,
  76. "Loop", 0,
  77. "AutoResponseType", 'auto reply',
  78. "OrigHeader", array(
  79. 'From' => $from,
  80. 'To' => 'SI',
  81. 'Subject' => $title,
  82. 'Body' => "ICI LA DEMANDE"
  83. ),
  84. ));
  85.  
  86. # A ticket is not usefull without at least one article. The function
  87. # returns an Article ID.
  88. $client->__soapCall("Dispatch",
  89. array($username, $password,
  90. "TicketObject", "ArticleCreate",
  91. "TicketID", $ticket_enfant1,
  92. "ArticleType", "webrequest",
  93. "SenderType", "customer",
  94. "HistoryType", "WebRequestCustomer",
  95. "HistoryComment", "created from PHP",
  96. "From", $from,
  97. "Subject", $title,
  98. "ContentType", "text/plain; charset=ISO-8859-1",
  99. "Body", "Demande de déménagement",
  100. "UserID", 1,
  101. "Loop", 0,
  102. "AutoResponseType", 'auto reply',
  103. "OrigHeader", array(
  104. 'From' => $from,
  105. 'To' => 'SI',
  106. 'Subject' => $title,
  107. 'Body' => "ICI LA DEMANDE"
  108. ),
  109. ));
  110.  
  111. # A ticket is not usefull without at least one article. The function
  112. # returns an Article ID.
  113. $client->__soapCall("Dispatch",
  114. array($username, $password,
  115. "TicketObject", "ArticleCreate",
  116. "TicketID", $ticket_enfant2,
  117. "ArticleType", "webrequest",
  118. "SenderType", "customer",
  119. "HistoryType", "WebRequestCustomer",
  120. "HistoryComment", "created from PHP",
  121. "From", $from,
  122. "Subject", $title,
  123. "ContentType", "text/plain; charset=ISO-8859-1",
  124. "Body", "Demande de déménagement",
  125. "UserID", 1,
  126. "Loop", 0,
  127. "AutoResponseType", 'auto reply',
  128. "OrigHeader", array(
  129. 'From' => $from,
  130. 'To' => 'SI',
  131. 'Subject' => $title,
  132. 'Body' => "ICI LA DEMANDE"
  133. ),
  134. ));
  135.  
  136.  
  137. $client->__soapCall("Dispatch",
  138. array($username, $password, "LinkObject", "LinkAdd",
  139. "SourceObject", "Ticket",
  140. "SourceKey", $ticket_parent,
  141. "TargetObject", "Ticket",
  142. "TargetKey" , $ticket_enfant1,
  143. "Type", "ParentChild",
  144. "Direction", "Target",
  145. "State" , "Valid",
  146. "UserID", 1
  147. ));
  148.  
  149. $client->__soapCall("Dispatch",
  150. array($username, $password, "LinkObject", "LinkAdd",
  151. "SourceObject", "Ticket",
  152. "SourceKey", $ticket_parent,
  153. "TargetObject", "Ticket",
  154. "TargetKey" , $ticket_enfant2,
  155. "Type", "ParentChild",
  156. "Direction", "Target",
  157. "State" , "Valid",
  158. "UserID", 1
  159. ));
  160.  
  161. # Print the info to the screen.
  162. echo "You have just created ticket id $ticket_parent.\n";
  163.  
  164. ?>
Add Comment
Please, Sign In to add comment