Hello There,
I have been trying to integrate Event Brite event creation process with my PHP application but could not figure out how to upload image-event-logo from given API sets on the Event brite website.
Please help me out with some sample code or any sandbox for PHP if possible.
Here is the code I have written.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Authorization: Bearer Token"
));
$response = curl_exec($ch);
curl_close($ch);
$img_up = json_decode($response, true);
if(@$_POST)
{
$postFields = [
'AWSAccessKeyId' => $img_up['upload_data']['AWSAccessKeyId'],
'bucket' => $img_up['upload_data']['bucket'],
'acl' => $img_up['upload_data']['acl'],
'Key' => $img_up['upload_data']['key'],
'signature' => $img_up['upload_data']['signature'],
'policy' => $img_up['upload_data']['policy'],
'file_parameter_name' => '@'.($_FILES['image']['tmp_name']) // Notice the '@' and use your input file name
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $img_up['upload_url']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postFields));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Authorization: Bearer " . $img_up['upload_token'],
"Content-Type: multipart/form-data"
));
$response = curl_exec($ch);
curl_close($ch);
}
?>
<form action="" method='POST' enctype="multipart/form-data">
<input type="file" name="image">
<input type="submit" name="submit">
</form>
Thanks in advance !