1

Working a poc on integrating Salesforce with Eventbrite. Want to have events created in Salesforce which automatically get created on eventbrite.

What do I do so that events gets created on eventbrite? Can you please help me with the sample code to proceed

This is what I am referring to https://www.eventbrite.com/developer/v3/

public class EventbriteCallBackController {
  Callbacktoken__c cfg = new Callbacktoken__c(SetupOwnerId = UserInfo.getUserId());

public void insertsettings() {
    insert cfg;
}
public EventbriteCallBackController(){
    String clientId = 'JSU646Y57T4RZ722ZP'; // Set this in step 3
    String clientSecret = '7F4LQ24WGPVULZPHPXNZP6CIWVUC7H5RXFTMZOSDAFAYDVPKYP'; // Set this in step 3

    String paramCode = ApexPages.currentPage().getParameters().get('code');
    system.debug('paramCode '+paramCode);

    Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setEndpoint('https://www.eventbrite.com/oauth/token');
    String body = 'code='+paramCode+'&client_secret='+clientSecret+'&client_id='+clientId+'&grant_type=authorization_code';
    req.setMethod('POST');
    req.setBody(body);
    req.setHeader('Content-Type','application/x-www-form-urlencoded');
    System.debug('Request is' +req);
    HttpResponse res = new HttpResponse();
    System.debug('response is' +res.getBody());

    Http h1 = new Http();
    HttpResponse res2 = h1.send(req);
    String resp = res2.getBody();
    System.debug('FINAL RESP IS:'+EncodingUtil.urlDecode(resp, 'UTF-8'));

     Map<string,object > results =(Map<string,object>)Json.deserializeuntyped(resp);
    cfg.access_token__c  = (string)results.get('access_token');

   }

1 Answer 1

0

Eventbrite supports webhooks: https://www.eventbrite.com/developer/v3/reference/webhooks/

Basically what it does it you post a web service to listen to a certain event, e.g. event created. When that event happens, the webhook will use the remote url you provided in original web service to callback and provide you with the information. So basically you should be using that to handle this scenario.

4
  • Doing this to lear webservices and as you see its a plain callout. Webhooks is surely an option. Other way, we need to write a trigger to fire the event, right ? If you can help me with the code for it as it as POST / event (Post request) to the eventbrite
    – JJoseph
    Commented Oct 14, 2016 at 5:56
  • @JJoseph your above code is pretty much how you do a post request to 3rd party web service. If you call that in a trigger, you need to put it into a future method. What is your issue with that?
    – Lance Shi
    Commented Oct 14, 2016 at 6:06
  • The above code does authentication / authorization and stores the access stoken. But , destiny is left, that is, If I create the event in Salesforce, automatically create the event on Eventbrite which this code does not do.
    – JJoseph
    Commented Oct 14, 2016 at 6:35
  • @JJoseph the code is similar, just use HttpRequest to do a post to the relevent endpoint with predefined format. But I can't write the code for your though
    – Lance Shi
    Commented Oct 14, 2016 at 7:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .