Привет, я пытаюсь получить данные sh, используя curl. Я должен добавить дайджест-значение, которое мне нужно создать с помощью HMA C, и отправить данные в виде кодов в форме. Моя проблема в том, что я получаю ошибку signature mismatch
, пока я пытаюсь получить данные sh.
Вот что я пробовал до сих пор:
Stringpayload="{\"gavisitorid\":\"1117878577.1576839389\",\"mobile\":\"999999999\"}"
$postdata = "";
$a = fopen('php://input' , 'r');
while (!feof($a))
{
$postdata .= fread($a, 4096);
}
$sk='EghAfDrNv4RrGpRv00BGiC3vCP49cwVAEIzT7ob5JFiEQS5oMg=='; // client secret key
$secret = base64_decode('EghAfDrNv4RrGpRv00BGiC3vCP49cwVAEIzT7ob5JFiEQS5oMg==');
$pad = hash_hmac('sha1', $postdata,$secret, true);
$digestvalue = bin2hex($pad);
Завиток:
$vars='ipru.Client_ID=web2Call&ipru.Bearer=Bearer_ParkingData&ipru.Payload='.$postdata;
$headers=['Content-Type:application/x-www-form-urlencoded','ipru.DigestValue:'.$digestvalue,'ipru.Access_token:'.$key]; //headers
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"urlgoeshere"); //icici data consume url
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($vars)); //sendinng post data
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$server_output = curl_exec ($ch);
curl_close ($ch);
Из документации API, как создать hma c и отправить данные:
, with a post request to start sending data.
For calculating the Digest value Please follow below Steps:
1) Get an hmac_sha1 key from the raw key bytes (Here raw key bytes will be the Client_secret
2) Compute the hmac on Payload bytes
3) Hex-encode the hmac(Hex encode instead of Base64 as mentioned in Example) and return the string obtained is the DigestValue
4) The algorithm used is: HmacSHA1
Пожалуйста, обратитесь к примеру 50 по ссылке ниже для получения дополнительной помощи: http://www.javatips.net/api/java.security.signatureexception
Hex encode instead of Base64 as mentioned in Example, Here Client_secret to be used instead of key as mentioned
in example
![enter image description here](https://i.stack.imgur.com/tzyTw.png)