WC_Helper_API::create_request_signature
Create signature for a request.
Метод класса: WC_Helper_API{}
Хуков нет.
Возвращает
Строку. The signature.
Использование
$result = WC_Helper_API::create_request_signature( $access_token_secret, $url, $method, $body ): string;
- $access_token_secret(строка) (обязательный)
- The access token secret.
- $url(строка) (обязательный)
- The URL to add the access token and signature to.
- $method(строка) (обязательный)
- The request method.
- $body(массив)
- The body of the request.
По умолчанию:null
Код WC_Helper_API::create_request_signature() WC Helper API::create request signature WC 10.5.2
private static function create_request_signature( string $access_token_secret, string $url, string $method, $body = null ): string {
$request_uri = wp_parse_url( $url, PHP_URL_PATH );
$query_string = wp_parse_url( $url, PHP_URL_QUERY );
if ( is_string( $query_string ) ) {
$request_uri .= '?' . $query_string;
}
$data = array(
'host' => wp_parse_url( $url, PHP_URL_HOST ),
'request_uri' => $request_uri,
'method' => $method,
);
if ( ! empty( $body ) ) {
$data['body'] = $body;
}
return hash_hmac( 'sha256', wp_json_encode( $data ), $access_token_secret );
}