PHP Examples

Sample: Creating a Background Burn

Code

<?php

$url = 'https://api.bonanza.com/api/background_burns';
$fields = ['key' => 'gpVpnYoedr0U2NX', 'user_id' => 1234,
    'url' => 'https://bonanzapublic.s3.amazonaws.com/images/background_burner/colorful_bag.jpg'];

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $fields);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($curl);

curl_close($curl);

?>

Data

{
  "action": "create",
  "message": "Successfully queued",
  "user_id": "1234",
  "burn_user_id": 60,
  "access_token": "xnD5WKcla7tg",
  "id": 5514,
  "url": "http://burner.bonanza.com/background_burns/5514",
  "position_in_queue": 0,
  "complete": false,
  "selected_mask_id": null,
  "final_result_url": null,
  "source_image_url": "http://images.bonanzastatic.com/uploads/burnees/1479239296-26885-0029-9944.jpg",
  "masks": [ ],
  "review_complete": false
}

Sample: Showing a Background Burn

Code

<?php

$burn_id = 5514;
$query = http_build_query(['key' => 'gpVpnYoedr0U2NX', 'user_id' => 1234]);
$url = "https://api.bonanza.com/api/background_burns/$burn_id?$query";

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($curl);

curl_close($curl);

?>

Data

{
  "action": "show",
  "message": "Found existing burn for user 1234 with id: 5514",
  "user_id": "1234",
  "burn_user_id": 60,
  "access_token": "xnD5WKcla7tg",
  "id": 5514,
  "url": "http://burner.bonanza.com/background_burns/5514",
  "position_in_queue": 0,
  "complete": false,
  "selected_mask_id": null,
  "final_result_url": null,
  "source_image_url": "http://images.bonanzastatic.com/uploads/burnees/1479239296-26885-0029-9944.jpg",
  "masks": [
    {
      "id": 6418,
      "url": "http://burner.bonanza.com/background_masks/6418.png?",
      "composite_url": "http://burner.bonanza.com/background_masks/6418.png?1479239596&composite=true&no_crop=false&transparent=false",
      "variation": "flooded",
      "quality_score": 505
    }
  ],
  "review_complete": false
}

Sample: Updating a Background Burn

Code

<?php

$burn_id = 5514;
$url = "https://api.bonanza.com/api/background_burns/$burn_id";
$fields = ['key' => 'gpVpnYoedr0U2NX', 'user_id' => 1234, 'selected_mask_id' => 6418];

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($curl, CURLOPT_POSTFIELDS, $fields);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($curl);

curl_close($curl);

?>

Data

{
  "action": "update",
  "message": "Saved final mask for burn with id: 5514",
  "user_id": "1234",
  "burn_user_id": 60,
  "access_token": "xnD5WKcla7tg",
  "id": 5514,
  "url": "http://burner.bonanza.com/background_burns/5514",
  "position_in_queue": 0,
  "complete": false,
  "selected_mask_id": 6418,
  "final_result_url": "http://images.bonanzastatic.com/uploads/burns/5514.jpg?1479239971",
  "source_image_url": "http://images.bonanzastatic.com/uploads/burnees/1479239296-26885-0029-9944.jpg",
  "masks": [
    {
      "id": 6418,
      "url": "http://burner.bonanza.com/background_masks/6418.png?",
      "composite_url": "http://burner.bonanza.com/background_masks/6418.png?1479239972&composite=true&no_crop=false&transparent=false",
      "variation": "flooded",
      "quality_score": 505
    }
  ],
  "review_complete": false
}

Sample: Deleting a Background Burn

Code

<?php

$burn_id = 5514;
$url = "https://api.bonanza.com/api/background_burns/$burn_id";
$fields = ['key' => 'gpVpnYoedr0U2NX', 'user_id' => 1234];

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($curl, CURLOPT_POSTFIELDS, $fields);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($curl);

curl_close($curl);

?>

Data

{
  "action": "destroy",
  "message": "Archived burn with id: 5514",
  "user_id": "1234",
  "burn_user_id": 60,
  "access_token": "xnD5WKcla7tg",
  "id": 5514,
  "url": "http://burner.bonanza.com/background_burns/5514",
  "position_in_queue": 0,
  "complete": false,
  "selected_mask_id": 6418,
  "final_result_url": "http://images.bonanzastatic.com/uploads/burns/5514.jpg?1479239971",
  "source_image_url": "http://images.bonanzastatic.com/uploads/burnees/1479239296-26885-0029-9944.jpg",
  "masks": [
    {
      "id": 6418,
      "url": "http://burner.bonanza.com/background_masks/6418.png?",
      "composite_url": "http://burner.bonanza.com/background_masks/6418.png?1479240242&composite=true&no_crop=false&transparent=false",
      "variation": "flooded",
      "quality_score": 505
    }
  ],
  "review_complete": false
}

Sample: Listing Background Burns

Code

<?php

$query = http_build_query(['key' => 'gpVpnYoedr0U2NX', 'user_id' => 1234]);
$url = "https://api.bonanza.com/api/background_burns?$query";

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($curl);

curl_close($curl);

?>

Data

{
  "action": "index",
  "message": "Success",
  "user_id": "1234",
  "burn_user_id": 60,
  "access_token": "xnD5WKcla7tg",
  "count": 3,
  "background_burns": [
    {
      "id": 5514,
      "url": "http://burner.bonanza.com/background_burns/5514",
      "position_in_queue": 0,
      "complete": false,
      "selected_mask_id": 6418,
      "final_result_url": "http://images.bonanzastatic.com/uploads/burns/5514.jpg?1479239971",
      "source_image_url": "http://images.bonanzastatic.com/uploads/burnees/1479239296-26885-0029-9944.jpg",
      "masks": [
        {
          "id": 6418,
          "url": "http://burner.bonanza.com/background_masks/6418.png?",
          "composite_url": "http://burner.bonanza.com/background_masks/6418.png?1479240113&composite=true&no_crop=false&transparent=false",
          "variation": "flooded",
          "quality_score": 505
        }
      ],
      "review_complete": false
    },
    {
      "id": 5513,
      "url": "http://burner.bonanza.com/background_burns/5513",
      "position_in_queue": 0,
      "complete": false,
      "selected_mask_id": null,
      "final_result_url": null,
      "source_image_url": "http://images.bonanzastatic.com/uploads/burnees/1479239229-26885-0028-7649.jpg",
      "masks": [
        {
          "id": 6417,
          "url": "http://burner.bonanza.com/background_masks/6417.png?",
          "composite_url": "http://burner.bonanza.com/background_masks/6417.png?1479240113&composite=true&no_crop=false&transparent=false",
          "variation": "flooded",
          "quality_score": 505
        }
      ],
      "review_complete": false
    },
    {
      "id": 5512,
      "url": "http://burner.bonanza.com/background_burns/5512",
      "position_in_queue": 0,
      "complete": false,
      "selected_mask_id": null,
      "final_result_url": null,
      "source_image_url": "http://images.bonanzastatic.com/uploads/burnees/1479239182-26885-0027-8632.jpg",
      "masks": [
        {
          "id": 6416,
          "url": "http://burner.bonanza.com/background_masks/6416.png?",
          "composite_url": "http://burner.bonanza.com/background_masks/6416.png?1479240113&composite=true&no_crop=false&transparent=false",
          "variation": "flooded",
          "quality_score": 505
        }
      ],
      "review_complete": false
    }
  ]
}