Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9242

Re: HTTP Call to Google Geocode

$
0
0

This is an example that works like our current solution:


DATA: lr_conv TYPE REF TO cl_abap_conv_in_ce,
plaintext
TYPE string.
DATA: lv_sign_key_x TYPE xstring,
lv_sign_key  
TYPE string,
lv_hmac_result
TYPE string,
lv_sign_string
TYPE string.
TYPE-POOLS: abap.

lv_sign_string
= url.

lv_sign_key
= 'your_sign_key'.

* String to SafeBase64

REPLACE ALL OCCURRENCES OF '_' IN lv_sign_key WITH '/'.
REPLACE ALL OCCURRENCES OF '-' IN lv_sign_key WITH '+'.

* Do not sign the protocol/domain
REPLACE 'http://maps.googleapis.com' IN lv_sign_string WITH ''.

*Convert key from String to xString (hex)
CALL FUNCTION 'SSFC_BASE64_DECODE'
EXPORTING
b64data
= lv_sign_key
IMPORTING
bindata
= lv_sign_key_x.

* Generate signature
cl_abap_hmac
=>calculate_hmac_for_char(
EXPORTING
if_algorithm    
= 'SHA1'
if_key          
= lv_sign_key_x
if_data         
= lv_sign_string
IMPORTING
ef_hmacb64string
= lv_hmac_result
).
* SafeBase64 -> Base64 again
REPLACE ALL OCCURRENCES OF '/' IN lv_hmac_result WITH '_'.
REPLACE ALL OCCURRENCES OF '+' IN lv_hmac_result WITH '-'.

* Concatenate final URL

CONCATENATE url '&signature=' lv_hmac_result INTO url
.



Best regards,


Hendrik Behrens


Viewing all articles
Browse latest Browse all 9242

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>