Upload API

In order to send a file you must perform an HTTP POST request to the following URL:

https://www.bffile.com/API/V1/
Example Code:


<?php
        $apiurl = "https://www.bffile.com/API/V1/";//Upload API
        $file = __DIR__."/123.txt";//File path to upload (first file)
        $file2 = "/path/to/fullfilename.ext";//File path to upload (second file), and so on
        $filename1 = '';//File name, including the Filename Extension (EX:demo.zip);If it is null, the system will get it automatically.
        $filename2 = '';/ //Second file name, and so on

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_URL,$apiurl);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, [
            'fileupload[0]' => curl_file_create($file, '', $filename1),
            'fileupload[1]' => curl_file_create($file2, '', $filename2), //Multiple files (and so on)
            'price' => '',//File price (free of documents, please leave blank)
            'comment' => '',//File description
            'api_token' => '',//Upload API Token(You can log in to the homepage to view; if left blank, it means visitors.)
            'password' => ''//File password
        ]);
        $result = curl_exec($ch);
        $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);

        if ($status_code == 200) { // OK
        $obj = json_decode($result, true);
        if ($obj['results']){
            foreach($obj['results'] as $subresult) {
                if(isset($subresult['error']) && $subresult['error']) {
                    echo $subresult['message']; // Error Message For Each file
                } else {
                    echo $subresult['filename'].'<br>';// Output filename
                    echo $subresult['md5'].'<br>';// Output file MD5
                    echo $subresult['deletehash'].'<br>';//Output file deletion hasg
                    echo $subresult['urlhash'].'<br>';//Output download URL hash
                    echo $subresult['filesize'].'<br>';//Output file size (byte)
                    echo $subresult['message'];//Show message(EX: Successful upload)
                }
            }
        }else{
            echo $obj['message'];//Show message
        }
        } else { // Error occured
        print($result);
        }

        if (!function_exists('curl_file_create')) { // support func for PHP <= 5.5

            function curl_file_create($filename, $mimetype = '', $postname = '') {
                return "@$filename;filename="
                        . ($postname ?: basename($filename))
                        . ($mimetype ? ";type=$mimetype" : '');
            }

        }
?>

Query API

In order to retrieve a detail on a given File you must perform an HTTP GET request to the following URL:

https://www.bffile.com/API/V1/query/
Example Code:
<?php
    $apiurl = "https://www.bffile.com/API/V1/query/";//Query API
    $file = "https://www.bffile.com/UGzC5a";//File to be queried
    //$file = "UGzC5a";//Can also use file hash query
    $apiquery = $apiurl.$file;

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_URL,$apiquery);
    $result = curl_exec($ch);
    $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    if ($status_code == 200) { // OK
        $obj = json_decode($result);
        if ($obj->filemd5 <> null){
            echo $obj->filename.'<br>';// Output filename
            echo $obj->filemd5.'<br>';//Output file MD5
            echo $obj->filesize.'<br>';//Output file size (byte)
            echo $obj->comment.'<br>';//Output file description
            echo $obj->credits_value.'<br>';//Output file price
            echo $obj->downloads.'<br>';// Output file downloads
            echo $obj->created.'<br>';// Output file upload time (GMT+0)
            }else{
            echo $obj->message;//Show message
            }
        } else { // Error occured
        print($result);
    }
?>