コード例 #1
0
ファイル: genSD.php プロジェクト: CMP-Studio/EmuObjectMover
function genSD($projectID)
{
    $file = genPDF($projectID, true);
    $info = getProjectInfo($projectID);
    $xml = "<Operation>\n    <Details>";
    $xml .= addParam("requesttemplate", "API");
    $xml .= addParam("requester", $info["name"]);
    $xml .= addParam("email", $info["email"]);
    $xml .= addParam("subject", $info["title"]);
    $xml .= addParam("description", $info["notes"]);
    $date = strtotime($info["duedate"]);
    $datestr = date("j F Y", $date) . ", 23:59:59";
    $xml .= addParam("Due Date", $datestr);
    $xml .= "</Details>\n          </Operation>";
    $key = getSDkey();
    $method = "ADD_REQUEST";
    $postvars = array("OPERATION_NAME" => $method, "TECHNICIAN_KEY" => $key, "INPUT_DATA" => $xml);
    $url = getSDBaseURL() . "sdpapi/request/";
    $res = postAPI($url, $postvars, null, false);
    $resp = simplexml_load_string($res);
    if (isset($resp->response->operation->Details[0]->workorderid)) {
        $wo = $resp->response->operation->Details[0]->workorderid;
        $url = getSDBaseURL() . "sdpapi/request/{$wo}/attachment?OPERATION_NAME=ADD_ATTACHMENT&TECHNICIAN_KEY={$key}";
        $fields = array("file" => '@' . $file);
        $headers = array('Content-Type: multipart/form-data');
        $res = postAPI($url, $fields, $headers, false, false);
        $resp = simplexml_load_string($res);
        if (isset($resp->response->operation->result->status)) {
            if ($resp->response->operation->result->status == "Success") {
                //complete
            }
        }
        return array('url' => getSDBaseURL() . "WorkOrder.do?woMode=viewWO&woID={$wo}", 'ID' => $wo);
    } else {
        return null;
    }
}
コード例 #2
0
ファイル: index.php プロジェクト: CMP-Studio/EmuObjectMover
<?php

require_once __DIR__ . "/../config.php";
require_once filepath() . "app/config/sdConfig.php";
require_once filepath() . "app/api.php";
$input = "<Operation>\n  <Details>\n    <parameter>\n      <name>requesttemplate</name>\n      <value>API</value>\n    </parameter>\n    <parameter>\n      <name>Priority</name>\n      <value>Normal</value>\n    </parameter>\n    <parameter>\n      <name>Requester</name>\n      <value>Russian, Regina</value>\n    </parameter>\n    <parameter>\n      <name>Description</name>\n      <value>This is a test</value>\n    </parameter>\n    <parameter>\n      <name>Due Date</name>\n      <value>24 September 2015, 12:00:00</value>\n    </parameter>\n    <parameter>\n      <name>Subject</name>\n      <value>API Test Part 3</value>\n    </parameter>\n  </Details>\n</Operation>";
$key = getSDkey();
$method = "ADD_REQUEST";
$postvars = array("OPERATION_NAME" => $method, "TECHNICIAN_KEY" => $key, "INPUT_DATA" => $input);
$url = getSDBaseURL() . "sdpapi/request/";
var_dump($url);
var_dump(postAPI($url, $postvars, null, false));