Asking for help on Event-brite image upload API integration with PHP

71 views
Skip to first unread message

Dharun Aashick

unread,
Mar 15, 2021, 8:51:24 AM3/15/21
to Eventbrite Developers
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 !

Eventbrite Developers

unread,
Mar 16, 2021, 4:16:54 PM3/16/21
to Eventbrite Developers
Hi and thanks for reaching out. Let's have you start by taking a look at this documentation which will walk you through the steps involved in uploading and associating an image. If you would prefer to use our CMS style interface on evenbrite.com, please create your entire event listing using that tool. If you're struggling with a particular step, please include additional details (request/response body) and we can look at that particular case. 

Also, this is the bare minimum JSON body for a purpose=listing structured content module:

{
"modules":[
{
"type": "text",
"layout": null,
"data": {
"body": {
"text": "<p>Text goes here.</p>",
"alignment": "left"
},
"display_restrictions": []
},
"semantic_purpose": null,
"timed_display": null,
"display_restrictions": []
}
],
"publish":true,
"purpose":"listing"

Best,
Donna

Reply all
Reply to author
Forward
0 new messages