Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function getToken()
- {
- date_default_timezone_set('Asia/Jakarta');
- $timeStamp = date('Y-m-d\TH:i:s.S\TP', time());
- $clientID = '1YoKYKwitX05HpWcYuNtzvHHWOk6mvpc';
- $stringToSign = $clientID . '|' . $timeStamp;
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_URL => 'https://sandbox.partner.api.bri.co.id/snap/v1.0/access-token/b2b',
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_ENCODING => '',
- CURLOPT_MAXREDIRS => 10,
- CURLOPT_TIMEOUT => 0,
- CURLOPT_FOLLOWLOCATION => true,
- CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
- CURLOPT_CUSTOMREQUEST => 'POST',
- CURLOPT_POSTFIELDS => '{ "grantType": "client_credentials" }',
- CURLOPT_HTTPHEADER => array(
- 'X-SIGNATURE: ' . $stringToSign,
- 'X-CLIENT-KEY: 1YoKYKwitX05HpWcYuNtzvHHWOk6mvpc',
- 'X-TIMESTAMP: ' . $timeStamp,
- 'Content-Type: application/json',
- ),
- ));
- $response = curl_exec($curl);
- curl_close($curl);
- echo $response;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement