Add a picture to an event via the eventbrite API ?

791 views
Skip to first unread message

Philippe Oursel

unread,
Oct 18, 2017, 11:07:32 AM10/18/17
to Eventbrite API
Hi !

I am actually working on a web application which uses the eventbrite api, I don't have any problem about creating an event with all the necessary informations, same for displaying them when I need to. 
My problem is about the event picture, the event page of an event on eventbrite is kinda "sad" without a picture. 

While reading the eventbrite api documentation I found out there is a "event.logo_id" parameter but I don't know how to use it and what it represent. Does anyone have more information about that ? Or is there any way to upload a picture for an event via the Api ?

Thanks in advance,

Philippe Oursel

PS : I code in PHP 

zerolfc

unread,
Oct 19, 2017, 5:16:29 AM10/19/17
to Eventbrite API
follow this step https://www.eventbrite.com/developer/v3/resources/uploads/

i can guide you if you need help :)

Philippe Oursel

unread,
Oct 19, 2017, 7:00:52 AM10/19/17
to Eventbrite API
Hi,

First of all thanks for your help, 

So I manage to get my "upload_token" and my "upload_url" link but I struggle at the step 2, I understand how it work but I doesn't even know how to start to make it work with "curlfile".

Maybe if it's not too much to ask can you give me an example code of what I will look like ?




zerolfc

unread,
Oct 19, 2017, 7:30:27 AM10/19/17
to Eventbrite API
hello,
I have created a snippet for you, you can try this code https://pastebin.com/UTrDPhKX

Message has been deleted

Philippe Oursel

unread,
Oct 19, 2017, 8:42:01 AM10/19/17
to Eventbrite API
I ask you a lot sorry (still a beginner) but can you explain these ligne :
  1. $eventBriteModel = new zerolfc\eventbrite\HttpClient( TOKEN );
  2.  
  3. $mediaResult = $eventBriteModel->get('/media/upload/', [
  4.   'type' => 'image-event-logo'
  5. ]);
  1.    $uploadResult = $eventBriteModel->post('/media/upload/', [
  2.     'upload_token' => $mediaResult['upload_token'],
  3.    ]);

Also you upload the picture with curl just before, so why do you have to do it again with $uploadResult ? There is something that I miss especially at the first ligne where you define $eventBriteModel

Philippe Oursel

unread,
Oct 19, 2017, 8:53:01 AM10/19/17
to Eventbrite API
Ok, after re reading the api documentation I understand the last part :

  1.    $uploadResult = $eventBriteModel->post('/media/upload/', [
  2.     'upload_token' => $mediaResult['upload_token'],
  3.    ]);
Correct me if I'm wrong but this is for notify the API that the upload work has completed, but I still doesn't understand this part to adapt it for myself :

  1. $eventBriteModel = new zerolfc\eventbrite\HttpClient( TOKEN );
  2.  
  3. $mediaResult = $eventBriteModel->get('/media/upload/', [
  4.   'type' => 'image-event-logo'
  5. ]);
:/

zerolfc

unread,
Oct 19, 2017, 9:00:43 AM10/19/17
to Eventbrite API
Im not sure if you are familiar with composer. https://getcomposer.org/doc/01-basic-usage.md#autoloading

If you use composer then you can use PSR-4 autoloading.

To download you need to install composer to your laptop. then you can use below code to install the package:

composer require zerolfc/eventbrite-sdk-php

then in your file
require 'vendor/autoload.php';

$eventBriteModel
= new zerolfc\eventbrite\HttpClient( TOKEN ); // zerolfc\evenbrite is a namespace

Or you can download the file from github.

This is how eventbrite `media/upload` works.

1) Retrieve the upload token that will include the upload data to their CDN Amazon S3

$mediaResult = $eventBriteModel->get('/media/upload/', [
  'type' => 'image-event-logo'
]);

2) Upload the image to their CDN using the CURL code

3) Notify the API upload has completed. This is when you use `upload_token`. Eventbrite is probably checking whether the upload_token matches with the Amazon Key and the image has been uploaded.

$uploadResult = $eventBriteModel->post('/media/upload/', [
    'upload_token' => $mediaResult['upload_token'],
]);
   

hope that helps

zerolfc

unread,
Oct 19, 2017, 9:03:53 AM10/19/17
to Eventbrite API
if you notice its HTTP method GET not POST, so this is to get the upload token 
Message has been deleted

Philippe Oursel

unread,
Oct 19, 2017, 10:31:37 AM10/19/17
to Eventbrite API
After some struggle it's ok everything work !!!! 

You can't imagine how much time you save me, i'm really grateful to you, thank a lot for your help :D

mi...@generalpie.com

unread,
Dec 5, 2017, 9:01:25 PM12/5/17
to Eventbrite API
I just can't get this to work at all. Curl gives me no information back, either as an error or a response. And then a POST request with the upload_token tells me 'upload_token' is an unknown parameter and it requires a 'type' parameter.

zerolfc

unread,
Dec 6, 2017, 4:16:24 AM12/6/17
to Eventbrite API
can you post your php code?

mi...@generalpie.com

unread,
Dec 6, 2017, 10:32:44 PM12/6/17
to Eventbrite API
I initially tried to use guzzle multipart but that kept giving me conflicting query parameter errors:

See here
https://stackoverflow.com/questions/47644875/struggling-with-s3-multipart-upload-guzzle-for-eventbrite


I then just switched to using your curl code

And then trying to make the final request using guzzle


I've had to chop out a few things here but this->client is the guzzle client
https://pastebin.com/nTsMqLDw

zerolfc

unread,
Dec 7, 2017, 4:42:09 AM12/7/17
to Eventbrite API
in your $postFields file, make sure its the tmp_name path NOT the full image path

 $_FILES[ {input-name} ]['tmp_name']


mi...@generalpie.com

unread,
Dec 7, 2017, 5:11:49 PM12/7/17
to Eventbrite API
I'm not using a form, this is an image that is already on the server executed by a cron job, so no tmp and no $_FILES
Reply all
Reply to author
Forward
0 new messages