Import some code from bitcasa-php-sdk