Using PHP to Develop with Binbox

The benefit of using Binbox is that your pastes are encrypted locally in your web browser. The encrypted data is sent to our servers and the password is stored safely in your browser's local storage. Because of this fact, there is no way to develop with Binbox on the server-side without the use of web browsers. The examples below are provided for demonstration purposes.


Download the PHP Library

You may download the PHP API Library at the following URL:
https://binbox.io/scripts/Binbox.API.php4.txt


Initializing the PHP Library

Include the Binbox Library:
Change api.binbox.io to your API URL: binbox.io

require_once("Binbox.API.php");
$bb = new Binbox('binbox.io');

API Methods


Shrinking a Link

URL: submit.json
$bb->api("submit.json", ['url' => 'http://exampledomain.com/', 'title' => 'Untitled']);

Parameters

  • options
    • url
      • The URL to be shortened.
    • title (optional)
      • A plaintext string, used in the dashboard as well as for display. Titles are not encrypted and limited to 40 characters. Defaults to "Untitled" when null or not set.
    • folder (optional)
      • A plaintext string, used in the dashboard as well as for display. Titles are not encrypted and limited to 40 characters. Defaults to "Untitled" when null or not set.

Example

$result = $bb->api("submit.json", ['url' => "http://exampledomain.com/", 'title' => 'Untitled']);
		
// result:  {"ok":true,"id":"ImIp4"}
		

Creating a Paste

URL: submit.json
$bb->api("submit.json", ['data' => $data, 'title' => 'Untitled']);

Parameters

  • options
    • data
      • The Base64-encoded data that is provided by our JavaScript SDK. Plaintext will not be accepted.
    • title
      • A plaintext string, used in the dashboard as well as for display. Titles are not encrypted and limited to 40 characters. Defaults to "Untitled" when null or not set.
    • folder (optional)
      • A plaintext string, used in the dashboard as well as for display. Titles are not encrypted and limited to 40 characters. Defaults to "Untitled" when null or not set.

Example

$result = $bb->api("submit.json", ['data' => "eyJpdiI6IklTYW0xMmczWld2NnExWDJVRUM1L3c9PSIsInYiOjEsIml0ZXIiOjEwMDAsImtzIjoxMjgsInRzIjo2NCwibW9kZSI6ImNjbSIsImFkYXRhIjoiIiwiY2lwaGVyIjoiYWVzIiwic2FsdCI6IndJUE5DcXZUMTcwPSIsImN0IjoiK0IxM3ZiclMvRUJZcm9aWCJ9", 'title' => 'Untitled']);
		
// result:  {"ok":true,"id":"ImIp4"}
		

Retrieving a Paste

pasteID.json
$bb->api($pasteID.".json");
		

Parameters

  • Paste ID (string)
  • Callback (function)

Example

$paste = $bb->api("ImIp4.json");
// result: {"ok":true,"paste":{"id":"ImIp4","author":null,"folder" : 0,"title":"Untitled","text":"{\"iv\":\"ISam12g3ZWv6q1X2UEC5\/w==\",\"v\":1,\"iter\":1000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"wIPNCqvT170=\",\"ct\":\"+B13vbrS\/EBYroZX\"}","is_deleted":"0","views":"0","timestamp":"2014-01-25 07:27:03"},"author":null}
		

Encrypting a Paste

Because we protect our pastes with Javascript-based encryption, it is not possible to encrypt or decrypt a paste without using the Javascript SDK