Skip to content

Instantly share code, notes, and snippets.

@Dweez
Created November 18, 2017 14:32
Show Gist options
  • Save Dweez/844d230b3ba855e4d5974af03e4172b8 to your computer and use it in GitHub Desktop.
Save Dweez/844d230b3ba855e4d5974af03e4172b8 to your computer and use it in GitHub Desktop.
Bullit API

API Bullit

Jquery Ajax :

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "YOUR_BULLIT_URL",
  "method": "POST",
  "headers": {
    "content-type": "application/x-www-form-urlencoded"
  },
  "data": {
    "api_key": "YOUR_API_KEY",
    "text": "Test POST jquery pour Metromix",
    "name": "team-a",
    "type": "Team A",
    "room": "YOUR_ROOM"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

cURL :

curl -X POST \
  YOUR_BULLIT_URL \
  -H 'content-type: application/x-www-form-urlencoded' \
  -d 'api_key=YOUR_API_KEY&text=Ceci%20est%20un%20test&name=metromix&type=MetromixAPI&room=YOUR_ROOM'

PHP (mod cURL)

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "YOUR_BULLIT_URL",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "api_key=YOUR_API_KEY&text=Ceci%20est%20un%20test%20PHP%20cURL&name=metromix&type=MetromixAPI&room=YOUR_ROOM",
  CURLOPT_HTTPHEADER => array(
    "content-type: application/x-www-form-urlencoded"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment