Php Sinch语音回调请求登录
我正在使用Sinch制作应用程序到手机的应用程序。 我正在成功地为ICE和ACE事件提供回调,无需请求登录。 但是现在,当我试图签署请求以使其更安全时,它总是无法满足要求 我从这里获取代码: 当我尝试使用来自的数据和应用程序密钥时,它会起作用 但当我尝试使用真实数据时,它总是失败Php Sinch语音回调请求登录,php,sinch,Php,Sinch,我正在使用Sinch制作应用程序到手机的应用程序。 我正在成功地为ICE和ACE事件提供回调,无需请求登录。 但是现在,当我试图签署请求以使其更安全时,它总是无法满足要求 我从这里获取代码: 当我尝试使用来自的数据和应用程序密钥时,它会起作用 但当我尝试使用真实数据时,它总是失败 $key = "xxxxxx-xxxx-xxxx-xxxx-xxxxxxx"; $secret = 'my-app-secret'; $body = $request->getC
$key = "xxxxxx-xxxx-xxxx-xxxx-xxxxxxx";
$secret = 'my-app-secret';
$body = $request->getContent();
$timestamp = $request->input('timestamp');
$path = '/sinch/callback/' . $callbackType;
$content_type = "application/json";
$canonicalized_headers = "x-timestamp:" . $timestamp;
$content_md5 = base64_encode( md5( utf8_encode($body), true ));
$string_to_sign =
"POST\n".
$content_md5."\n".
$content_type."\n".
$canonicalized_headers."\n".
$path;
$signature = base64_encode(hash_hmac("sha256", utf8_encode($string_to_sign), base64_decode($secret), true));
$authorizationHeader = $request->header('Authorization');
$sinchAuthorizationHeader = str_replace('Application ', '', $authorizationHeader);
$sinchAuthorizationHeader = explode(':', $sinchAuthorizationHeader);
if($sinchAuthorizationHeader[0] == $key && $signature == $sinchAuthorizationHeader[1]) {
return true;
}
return false;
如有任何帮助,我们将不胜感激。请看我在问题中所描述的这个Hi@cjensen。我从那个线程中得到了我的代码。