Last active
September 2, 2015 19:53
-
-
Save jwcobb/9ce71e3b88b8308e18fa to your computer and use it in GitHub Desktop.
Hacky workaround for apparent Guzzle issue when uploading JSON body > 1MB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function uploadEticketsForAnOrder(array $array = [], $token, $secret) | |
{ | |
$orderId = $array['order_id']; | |
$url = 'https://api.ticketevolution.com/v9/orders/' . $orderId . '/deliver_etickets'; | |
$data_string = '{"etickets":' . json_encode($array['etickets']) . '}'; | |
$stringToSign = 'POST ' . preg_replace('/https:\/\/|\?.*/', '', $url) . '?' . $data_string; | |
$signature = base64_encode(hash_hmac('sha256', $stringToSign, $secret, true)); | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_VERBOSE, false); | |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, [ | |
'Content-Type: application/json', | |
'Content-Length: ' . strlen($data_string), | |
'X-Token: ' . $token, | |
'X-Signature: ' . $signature, | |
'Expect:', | |
'Accept: application/json', | |
]); | |
$result = curl_exec($ch); | |
curl_close($ch); | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: