Get signature with php


#1

I’m working through the Creating a Signature Doc here:

https://dev.twitter.com/docs/auth/creating-signature

I’ve taken the signature base string, and the signing key, in the example, and passed it to the hash_hmac function, as recommended in the doc:

View http://ideone.com/6hdU2y to see that I can get the correct binary from the hash_hmac function.

Now, to convert it to base64, I believe that I can use PHP’s base64_encode() function. But this gives me an incorrect value:

YjY3OWMwYWYxOGY0ZTljNTg3YWI4ZTIwMGFjZDRlNDhhOTNmOGNiNg==

View http://ideone.com/Bu0CZi to see the function in action.

What am I doing wrong? Note, that I’ve also tried to convert to uppercase and include spaces before the base64_encode() function.