Skip to content

Instantly share code, notes, and snippets.

@jwcobb
Created October 15, 2012 20:26
Show Gist options
  • Save jwcobb/3895177 to your computer and use it in GitHub Desktop.
Save jwcobb/3895177 to your computer and use it in GitHub Desktop.
Debug Ticket Evolution order creation
// Setup & format your order stuff for the $options variable
$apiMethod = 'createOrders';
// Execute the call
try {
$results = $tevo->$apiMethod($options);
} catch (Exception $e) {
echo '<h1>Exception thrown trying to perform API request</h1>' . PHP_EOL
. _getRequest($tevo, $apiMethod, true)
. _getResponse($tevo, $apiMethod, true);
exit (1);
}
/**
* Utility function for returning formatted API request info
*
* @param TicketEvolution_Webservice $tevo
* @param string $apiMethod
* @param bool $isException
* @return string
*/
function _getRequest($tevo, $apiMethod, $isException=true)
{
$color = ($isException) ? '#f00' : '#ddd';
$html = '<h2>Actual request for ' . $apiMethod . '() method</h2>' . PHP_EOL
. '<pre style="background-color: ' . $color . '">' . PHP_EOL
. print_r ($tevo->getRestClient()->getHttpClient()->getLastRequest(), true)
. '</pre><br />' . PHP_EOL;
return $html;
}
/**
* Utility function for returning formatted API response info
*
* @param TicketEvolution_Webservice $tevo
* @param string $apiMethod
* @param bool $isException
* @return string
*/
function _getResponse($tevo, $apiMethod, $isException=true)
{
$color = ($isException) ? '#f00' : '#ddd';
$html = '<h2>Actual response for ' . $apiMethod . '() method</h2>' . PHP_EOL
. '<pre style="background-color: ' . $color . '">' . PHP_EOL
. print_r ($tevo->getRestClient()->getHttpClient()->getLastResponse(), true)
. '</pre><br />' . PHP_EOL;
return $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment