PHP code example of cyvax / privatebin_php

1. Go to this page and download the library: Download cyvax/privatebin_php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cyvax / privatebin_php example snippets


use Cyvax\Clients\Privatebin;

$result = (new Privatebin())
    ->setUrl("https://privatebin.net/")
    ->setText("Because ignorance is bliss!")
    ->setExpire("1hour")
    ->encodeAndPost();

use Cyvax\Clients\Privatebin;

$result = Privatebin::init(
    url: "https://privatebin.net/",
    text: "Because ignorance is bliss!",
    expire: "1hour",
)->encodeAndPost();

use Cyvax\Clients\PrivatebinSnakeCase;

$result = (new PrivatebinSnakeCase())
    ->set_url("https://privatebin.net/")
    ->set_text("Because ignorance is bliss!")
    ->set_expire("1hour")
    ->encode_and_post();

use Cyvax\Clients\Privatebin;

$result = (new Privatebin([
    "url"  => "https://privatebin.net/",
    "text" => "Because ignorance is bliss!",
]))->encodeAndPost();

use Cyvax\Clients\Privatebin;

$result = (new Privatebin())
    ->setAttachment("/path/to/image.png")
    ->encodeAndPost();

->setAttachment("/path/to/image.png", "screenshot.png")

use Cyvax\Clients\Privatebin;

$result = (new Privatebin())
    ->setUrl("https://local.privatebin/")
    ->setSslVerify(false)
    ->setText("Hello!")
    ->encodeAndPost();

use Cyvax\Clients\PrivatebinPipe;

$result = PrivatebinPipe::init("https://privatebin.net/")
    |> PrivatebinPipe::text("Hello!")
    |> PrivatebinPipe::expire("1hour")
    |> PrivatebinPipe::encodeAndPost();

use Cyvax\Clients\PrivatebinPipe;

$client = PrivatebinPipe::init("https://privatebin.net/");

$client = PrivatebinPipe::text("Hello!")($client);
$client = PrivatebinPipe::expire("1hour")($client);

$result = PrivatebinPipe::encodeAndPost()($client);

use Cyvax\Clients\Privatebin;

$client = new Privatebin();

// Fetch and decrypt in one call
$data = $client->fetchAndDecrypt($pasteId, $b58);

echo $data['paste'];
// $data['attachment'] and $data['attachment_name'] are set if the paste had an attachment

use Cyvax\Contracts\PrivatebinClientInterface;

function postPaste(PrivatebinClientInterface $client): array {
    return $client->setText("Hello!")->encodeAndPost();
}
bash
composer