<commit_before><?php

	//implements https://docs.exchange.coinbase.com/

	class coinbase {
		protected $api_key;
		protected $api_secret;
		protected $trading_url = "https://api.exchange.coinbase.com";
		
		public function __construct($api_key, $api_secret,$passphrase) 
		{
			$this->api_key = $api_key;
			$this->api_secret = $api_secret;
			$this->passphrase = $passphrase;
		}
			
		public function query( $method, $params = array(), $type = "GET" ) 
		{

			/*echo "\n\n";
			echo "$method";
			echo "\n";
			print_r( $params );
			echo "\n";
			echo "$type";
			echo "\n\n";*/

			usleep( 100000 ); //sleep for 1/10th of second so don't overload server...

			$key = $this->api_key;
			$secret = $this->api_secret;
			$passphrase = $this->passphrase;

			$time = time();
			$url = $this->trading_url . $method;

			$body = (!empty($params) ? json_encode($params) : '');

			$data = $time.$type.$method.$body;

			$sign = base64_encode( hash_hmac("sha256", $data, base64_decode( $secret ), true ) );                

			$headers = array(
				'User-Agent: Coinbase Compatible PHP',
				'Content-Type: application/json',
				'CB-ACCESS-KEY: '.$key,
				'CB-ACCESS-SIGN: '.$sign,
				'CB-ACCESS-TIMESTAMP: '.$time,
				'CB-ACCESS-PASSPHRASE: '.$passphrase
			);

			static $ch = null;

			if (is_null($ch)) {
				$ch = curl_init();
				curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
				curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36');
			}

			curl_setopt($ch, CURLOPT_URL, $url);
			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);

			if( $type == "POST" ) {
				curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
			}
			
			curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
			curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

			// run the query
			$res = curl_exec($ch);

			if ($res === false) 
				throw new Exception('Curl error: '.curl_error($ch));

			$dec = json_decode($res, true);
			
			return $dec;

		}
		
		protected function retrieveJSON($URL) {
			$opts = array('http' =>
				array(
					'method'  => 'GET',<commit_msg>fixed forgotten verify host<commit_after><?php

	//implements https://docs.exchange.coinbase.com/

	class coinbase {
		protected $api_key;
		protected $api_secret;
		protected $trading_url = "https://api.exchange.coinbase.com";
		
		public function __construct($api_key, $api_secret,$passphrase) 
		{
			$this->api_key = $api_key;
			$this->api_secret = $api_secret;
			$this->passphrase = $passphrase;
		}
			
		public function query( $method, $params = array(), $type = "GET" ) 
		{

			$key = $this->api_key;
			$secret = $this->api_secret;
			$passphrase = $this->passphrase;

			$time = time();
			$url = $this->trading_url . $method;

			$body = (!empty($params) ? json_encode($params) : '');

			$data = $time.$type.$method.$body;

			$sign = base64_encode( hash_hmac("sha256", $data, base64_decode( $secret ), true ) );                

			$headers = array(
				'User-Agent: Coinbase Compatible PHP',
				'Content-Type: application/json',
				'CB-ACCESS-KEY: '.$key,
				'CB-ACCESS-SIGN: '.$sign,
				'CB-ACCESS-TIMESTAMP: '.$time,
				'CB-ACCESS-PASSPHRASE: '.$passphrase
			);

			static $ch = null;

			if (is_null($ch)) {
				$ch = curl_init();
				curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
				curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36');
			}

			curl_setopt($ch, CURLOPT_URL, $url);
			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);

			if( $type == "POST" ) {
				curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
			}
			
			curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
			curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);

			// run the query
			$res = curl_exec($ch);

			if ($res === false) 
				throw new Exception('Curl error: '.curl_error($ch));

			$dec = json_decode($res, true);
			
			return $dec;

		}
		
		protected function retrieveJSON($URL) {
			$opts = array('http' =>
				array(
					'method'  => 'GET',
{'fraction_non_alphanumeric': 0.17429837518463812, 'fraction_numerical': 0.016494337764647957, 'mean_word_length': 3.227887617065557, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6181572', 'n_tokens_mistral': 1863, 'n_tokens_neox': 1480, 'n_words': 297}