Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class BDB_API {
- private $base_url = 'http://api.bdb.io/';
- private $integration;
- private $api_username;
- private $api_password;
- function __construct( $api_username , $api_password , $integration ) {
- if( strlen( $api_username ) == 0 ) {
- throw new Exception('$api_username cannot be empty');
- } else {
- $this->api_username = $api_username;
- }
- if( strlen( $api_password ) == 0 ) {
- throw new Exception('$api_password cannot be empty');
- } else {
- $this->api_password = $api_password;
- }
- if( strlen( $integration ) == 0 ) {
- throw new Exception('$integration cannot be empty');
- } else {
- $this->integration = $integration;
- }
- }
- function run( $query = array() ) {
- $query = (array)$query;
- $query['integration'] = $this->integration;
- $query['api_username'] = $this->api_username;
- $query['api_password'] = $this->api_password;
- $ch = curl_init();
- $ch_options = array(
- CURLOPT_URL => $this->base_url,
- CURLOPT_POST => TRUE,
- CURLOPT_POSTFIELDS => http_build_query( $query ),
- CURLOPT_FOLLOWLOCATION => TRUE,
- CURLOPT_SSL_VERIFYHOST => FALSE,
- CURLOPT_RETURNTRANSFER => TRUE,
- );
- curl_setopt_array($ch, $ch_options);
- $results = curl_exec($ch);
- curl_close($ch);
- return $results;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement