Created
June 18, 2019 10:53
-
-
Save orhanbhr/1ea1b132a5a0eef2f301c811f7c28d83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$data_string = json_encode([ | |
'game_id' => '55f2dc09ba36f81816000001', | |
'balance' => '123', | |
'currency' => 'EUR', | |
'locale' => 'en', | |
'player_id' => 'asdf', | |
'callback' => $this->callBackUrl, | |
'rollback_callback' => $this->rollBackCallBackUrl, | |
'bonus_callback' => $this->bonusCallBackUrl, | |
'demo' => false, | |
'variant' => 'desktop', | |
]); | |
$nonce = rand() << 32 | rand(); | |
$message = '/v2/session' . $nonce . hash('sha256', $data_string); | |
$signature = hash_hmac('sha512', $message, $this->apiSecret); | |
$ch = curl_init($this->apiUrl . 'v2/session'); | |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, [ | |
'Content-Type: application/json', | |
'Content-Length: ' . strlen($data_string), | |
'X-Bg-Api-Key: ' . $this->apiKey, | |
'X-Bg-Nonce: ' . $nonce, | |
'X-Bg-Signature: ' . $signature | |
]); | |
$result = curl_exec($ch); | |
echo '<pre>'; print_r($result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment