File: src/Bintable/BintableApi.php

Recommend this page to a friend!
  Classes of Samy Massoud  >  PHP BIN Lookup API  >  src/Bintable/BintableApi.php  >  Download  
File: src/Bintable/BintableApi.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP BIN Lookup API
Lookup bank issuer number data using BinTable API
Author: By
Last change:
Date: 5 months ago
Size: 1,388 bytes
 

Contents

Class file image Download
<?php
namespace Bintable;

/**
 * @description Bintable Lookup API PHP Package
 * @author Bintable.com
 * @since 14/02/2020
 */
class BintableApi{
    private
$base_url = 'https://api.bintable.com/v1/';
    private
$api_key;
   
    public function
__construct($api_key="",$proxy=[]){
        if(!
$api_key){
            throw new \
Exception('Please provide API Key');
        }

       
$this->api_key = $api_key;
    }

   
/**
     * @description Lookup Bin Meta Information
     */
   
public function Lookup($bin){
       
$url = $this->base_url.$bin.'?api_key='.$this->api_key;
        return
$this->_curl($url);
    }

   
/**
     * @description Get account balance
     */
   
public function Balance(){
       
$url = $this->base_url.'balance?api_key='.$this->api_key;
        return
$this->_curl($url);
    }

   
/**
     * @description Get the API using CURl and fallback in case it doesn't exist
     */
   
private function _curl($url){
        if (!
function_exists('curl_init')){
            return
file_get_contents($url);
        }

       
$ch = curl_init();
       
curl_setopt($ch, CURLOPT_URL, $url);
       
curl_setopt($ch, CURLOPT_REFERER, gethostname());
       
curl_setopt($ch, CURLOPT_USERAGENT, "Bintable.com PHP API");
       
curl_setopt($ch, CURLOPT_TIMEOUT, 60);

       
$output = curl_exec($ch);
       
curl_close($ch);
        return
$output;
    }
}


For more information send a message to info at phpclasses dot org.