07-16-2012, 10:17 PM
Going from this webpage: https://dev.twitter.com/docs/auth/creating-signature
I've been able to write a QM script that outputs the correct binary string "B6 79 C0 AF 18 F4 E9 C5 87 AB 8E 20 0A CD 4E 48 A9 3F 8C B6"
The trouble is when the string is encrypted Base64 returns:
QjYgNzkgQzAgQUYgMTggRjQgRTkgQzUgODcgQUIgOEUgMjAgMEEgQ0QgNEUgNDggQTkgM0YgOEMg
QjY=
But according to the webpage, supposed to be: "tnnArxj06cWHq44gCs1OSKk/jLY="
Function OAuthSignature
I've been able to write a QM script that outputs the correct binary string "B6 79 C0 AF 18 F4 E9 C5 87 AB 8E 20 0A CD 4E 48 A9 3F 8C B6"
The trouble is when the string is encrypted Base64 returns:
QjYgNzkgQzAgQUYgMTggRjQgRTkgQzUgODcgQUIgOEUgMjAgMEEgQ0QgNEUgNDggQTkgM0YgOEMg
QjY=
But according to the webpage, supposed to be: "tnnArxj06cWHq44gCs1OSKk/jLY="
Function OAuthSignature
REPLACERX r.frepl=&replacerx_UCASE
;;/
;function# REPLACERXCB&x
;x.match.ucase
str HTTP_method="POST"
str URL="https://api.twitter.com/1/statuses/update.json"
str Consumer_secret="kAcSOqF21Fu85e7zjz7ZN2U4ZRhfV3WpwPAoE3Z7kBw"
str OAuth_token_secret="LswwdoUaIvS8ltyTt5jkRh4J50vUPVVHtR2YPi5kE"
str status="Hello Ladies + Gentlemen, a signed OAuth request!"
str include_entities="true"
str oauth_consumer_key="xvz1evFS4wEEPTGEFPHBog"
str oauth_nonce="kYjzVBB8Y0ZFabxSWbWovY3uYSQ2pTgmZeNu2VS4cg"
str oauth_signature_method="HMAC-SHA1"
str oauth_timestamp="1318622958"
str oauth_token="370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb"
str oauth_version="1.0"
;;;how to escape all these in one line?
HTTP_method.escape(9)
URL.escape(9)
Consumer_secret.escape(9)
OAuth_token_secret.escape(9)
status.escape(9)
include_entities.escape(9)
oauth_consumer_key.escape(9)
oauth_nonce.escape(9)
oauth_signature_method.escape(9)
oauth_timestamp.escape(9)
oauth_token.escape(9)
oauth_version.escape(9)
str Parameter_string=
F
;include_entities={include_entities}
;&oauth_consumer_key={oauth_consumer_key}
;&oauth_nonce={oauth_nonce}
;&oauth_signature_method={oauth_signature_method}
;&oauth_timestamp={oauth_timestamp}
;&oauth_token={oauth_token}
;&oauth_version={oauth_version}
;&status={status}
Parameter_string.findreplace("[]")
Parameter_string.replacerx("\%[\d\w]{2}" &r)
Parameter_string.escape(9)
str signature_base=F"{HTTP_method}&{URL}&{Parameter_string}"
str signing_key=F"{Consumer_secret}&{OAuth_token_secret}"
signature_base.replacerx("\%[\d\w]{2}" &r)
signing_key.replacerx("\%[\d\w]{2}" &r)
str OAuth_signature.HMAC_SHA1(signature_base signing_key)
OAuth_signature.encrypt(8 OAuth_signature "" 1)
OAuth_signature.trim
OAuth_signature.encrypt(4)
out OAuth_signature