public function before_request( &$url, &$headers, &$data )
	{
		// generate a date string
		$date            = new \DateTime('NOW', new \DateTimeZone("GMT"));
		$headers['Date'] = $date->format("D, d M Y H:i:s \G\M\T");

		// build up the data to be signed
		$request_data = $headers['Date']."\n".$url."\n";
		if( !empty($data) )
		{
			$request_data .= http_build_query($data);
		}

		// get a signature for our request

		// private key is in hex form, needs to be converted into PrivateKey Object
		$generator   = EccFactory::getNistCurves()->generator256();
		$private_key = new PrivateKey($this->math_adapter, $generator, $this->math_adapter->hexDec($this->private_key));

		$hash         = $this->math_adapter->hexDec(hash("sha256", $request_data));
		$signer       = EccFactory::getSigner();
		$randomK      = RandomGeneratorFactory::getRandomGenerator()->generate($private_key->getPoint()->getOrder());
		$signatureObj = $signer->sign($private_key, $hash, $randomK);
		$signature    = $this->math_adapter->decHex($signatureObj->getR()).$this->math_adapter->decHex($signatureObj->getS());

		// apply the HTTP headers and send the request
		$headers['X-Service']   = $this->service_name;
		$headers['X-Signature'] = $signature;

		if( $this->debug )
		{
			echo "\n\nRequest Data\n\n";

			echo "URL:\n";
			var_dump($url);

			echo "HEADERS:\n";
			var_dump($headers);

			echo "DATA:\n";
			var_dump($data);
		}
	}
public function before_request( &$url, &$headers, &$data )
	{
		// generate a date string
		$date            = new \DateTime('NOW', new \DateTimeZone("GMT"));
		$headers['Date'] = $date->format("D, d M Y H:i:s \G\M\T");

		// build up the data to be signed
		$request_data = $headers['Date']."\n".$url."\n";
		if( !empty($data) )
		{
			$request_data .= http_build_query($data);
		}

		// get a signature for our request

		// private key is in hex form, needs to be converted into PrivateKey Object
		$generator   = EccFactory::getNistCurves()->generator256();
		$private_key = new PrivateKey($this->math_adapter, $generator, $this->math_adapter->hexDec($this->private_key));

		$hash         = $this->math_adapter->hexDec(hash("sha256", $request_data));
		$signer       = EccFactory::getSigner();
		$randomK      = RandomGeneratorFactory::getRandomGenerator()->generate($private_key->getPoint()->getOrder());
		$signatureObj = $signer->sign($private_key, $hash, $randomK);
		$signature    = $this->math_adapter->decHex($signatureObj->getR()).$this->math_adapter->decHex($signatureObj->getS());

		// apply the HTTP headers and send the request
		$headers['X-Service']   = $this->service_name;
		$headers['X-Signature'] = $signature;

		if( $this->debug )
		{
			echo "\n\nRequest Data\n\n";

			echo "URL:\n";
			var_dump($url);

			echo "HEADERS:\n";
			var_dump($headers);

			echo "DATA:\n";
			var_dump($data);
		}
	}
public function before_request ( & $ url , & $ headers , & $ data ) { // generate a date string $ date = new \ DateTime ( 'NOW' , new \ DateTimeZone ( "GMT" ) ) ; $ headers [ 'Date' ] = $ date -> format ( "D, d M Y H:i:s \G\M\T" ) ; // build up the data to be signed $ request_data = $ headers [ 'Date' ] . "\n" . $ url . "\n" ; if ( ! empty ( $ data ) ) { $ request_data .= http_build_query ( $ data ) ; } // get a signature for our request // private key is in hex form, needs to be converted into PrivateKey Object $ generator = EccFactory :: getNistCurves ( ) -> generator256 ( ) ; $ private_key = new PrivateKey ( $ this -> math_adapter , $ generator , $ this -> math_adapter -> hexDec ( $ this -> private_key ) ) ; $ hash = $ this -> math_adapter -> hexDec ( hash ( "sha256" , $ request_data ) ) ; $ signer = EccFactory :: getSigner ( ) ; $ randomK = RandomGeneratorFactory :: getRandomGenerator ( ) -> generate ( $ private_key -> getPoint ( ) -> getOrder ( ) ) ; $ signatureObj = $ signer -> sign ( $ private_key , $ hash , $ randomK ) ; $ signature = $ this -> math_adapter -> decHex ( $ signatureObj -> getR ( ) ) . $ this -> math_adapter -> decHex ( $ signatureObj -> getS ( ) ) ; // apply the HTTP headers and send the request $ headers [ 'X-Service' ] = $ this -> service_name ; $ headers [ 'X-Signature' ] = $ signature ; if ( $ this -> debug ) { echo "\n\nRequest Data\n\n" ; echo "URL:\n" ; var_dump ( $ url ) ; echo "HEADERS:\n" ; var_dump ( $ headers ) ; echo "DATA:\n" ; var_dump ( $ data ) ; } }
before_request
Hook for PHP Requests

@param $url
@param $headers
@param $data
before_request Hook for PHP Requests