function returnJson($affectedNo, $message, $notAffectedNo, $errorMessage, $hiperlink) { $returnJson = array(); $returnJson['hiperlink'] = $hiperlink; $returnJson['messages'][] = buildMessage('affected', $affectedNo, $message); $returnJson['messages'][] = buildMessage('notAffected', $notAffectedNo, $errorMessage); return json_encode($returnJson); }
} // If nickname not provided if (!isset($item['nickname'])) { // If this is message to visitor or message to operator if (in_array($item['kind'], ['MessageToOperator', 'OfflineMessage'])) { // ~> Nick name is visitor full name $item['nickname'] = $data['visitor']['fullName']; } else { // Else // ~> Nick name is operator (Operator always has nick name) $item['nickname'] = 'Operator'; } } $conversionMessages .= $item['nickname'] . ": " . $item['body'] . PHP_EOL; } $data['conversionMessages'] = $conversionMessages; // If only offline message and this is not offline if ($app['offline_only'] && !$offline) { // ~> return false return new JsonResponse(['success' => false, 'error' => 'Not an offline message']); } $url = 'https://' . $app['freshdesk_api_key'] . ':X@' . $app['freshdesk_subdomain'] . '.freshdesk.com'; $conf = new Connection($url); $t = new Ticket($conf); //create new ticket $model = new TicketM(array('subject' => buildMessage($app['ticket_subject'], $data), 'description' => buildMessage($app['ticket_description'], $data), 'email' => $data['visitor']['emailAddress'])); //create new ticket, basic example $result = $t->createNewTicket($model); return new JsonResponse(['success' => $result != false]); }); $app->run();
$message = $mess[$_GET["m"]]; } ?> <?php getHeader("admin"); ?> <h3>Create a New Ad</h3> <?php echo $biz->buildCard(); ?> <?php echo buildMessage($message); ?> <form action="<?php echo $_SERVER["PHP_SELF"]; ?> ?id=<?php echo $_GET["id"]; ?> " method="post" enctype="multipart/form-data"> <table class="form"> <tr> <td class="field-name">Upload/Change Image:</td> <td class="field-value"> <?php
function showResult($method, $message) { print buildMessage(OK_RESULT, $method, $message); }
die('Curl module not installed!' . PHP_EOL); } $route = '/ping'; //$route = '/test/4'; //$route = '/doesntexist'; //$route = '/skip/auth'; if (isset($argv[1])) { $host = 'http://' . $argv[1] . $route; } else { $host = "http://api.example.com" . $route; } $privateKey = '593fe6ed77014f9507761028801aa376f141916bd26b1b3f0271b5ec3135b989'; $time = time(); $id = 1; $data = ['name' => 'bob']; $message = buildMessage($time, $id, $data); $hash = hash_hmac('sha256', $message, $privateKey); $headers = ['API_ID: ' . $id, 'API_TIME: ' . $time, 'API_HASH: ' . $hash]; $ch = curl_init(); curl_setopt($ch, CURLOPT_VERBOSE, TRUE); curl_setopt($ch, CURLOPT_URL, $host); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_HEADER, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE); $result = curl_exec($ch); if ($result === FALSE) { echo "Curl Error: " . curl_error($ch); } else {