<?php
function req($method,$url,$headers=[],$body=null){$raw=$body===null?'':json_encode($body,JSON_UNESCAPED_SLASHES);$headers[]='Accept: application/json';if($raw!=='')$headers[]='Content-Type: application/json';$ch=curl_init($url);curl_setopt_array($ch,[CURLOPT_RETURNTRANSFER=>true,CURLOPT_HEADER=>true,CURLOPT_CUSTOMREQUEST=>$method,CURLOPT_TIMEOUT=>30,CURLOPT_HTTPHEADER=>$headers]);if($raw!=='')curl_setopt($ch,CURLOPT_POSTFIELDS,$raw);$res=curl_exec($ch);$status=curl_getinfo($ch,CURLINFO_RESPONSE_CODE);$hs=curl_getinfo($ch,CURLINFO_HEADER_SIZE);curl_close($ch);$text=$res===false?'':substr($res,$hs);return [$status,$text,json_decode($text,true)];}
function hmacReq($method,$base,$path,$key,$secret){$raw='';$ts=(string)time();$nonce=bin2hex(random_bytes(12));$canonical=implode("\n",[$method,$path,$ts,$nonce,hash('sha256',$raw)]);$sig=hash_hmac('sha256',$canonical,$secret);return req($method,$base.$path,['x-api-key: '.$key,'x-api-timestamp: '.$ts,'x-api-nonce: '.$nonce,'x-api-signature: v1='.$sig]);}
$base='http://127.0.0.1:8001';
[$s,$b,$j]=req('POST',$base.'/api/v1/auth/login',[],['email'=>'ahmadshahzaib2490+3@gmail.com','password'=>'waqas123waqas']);
$token=$j['data']['token']??'';
[$s,$b,$j]=req('POST',$base.'/api/v1/api-keys',['Authorization: Bearer '.$token],['environment'=>'sandbox','scopes'=>['payments:read','balances:read','payouts:read','wallets:read']]);
$key=$j['data']['public_key']??'';$secret=$j['data']['secret']??'';
[$s,$b,$j]=hmacReq('GET',$base,'/api/v1/dashboard/summary',$key,$secret);
echo "status=$s\n";echo substr($b,0,1200);