30.07.2012 Views

Reference Guide

Reference Guide

Reference Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Example<br />

When sending the following API request:<br />

POST /ZendServer/Api/findTheFish HTTP/1.1<br />

Host: zscm.local:10081<br />

User-agent: Zend_Http_Client/1.10<br />

Accept: application/vnd.zend.serverapi+xml;version=1.0<br />

Date: Sun, 11 Jul 2010 13:16:10 GMT<br />

Content-type: application/x-www-form-urlencoded<br />

Content-length: 19<br />

lookInCupboard=TRUE<br />

Using a key named “angel.eyes” with the following value:<br />

Web API <strong>Reference</strong> <strong>Guide</strong><br />

9dc7f8c5ac43bb2ab36120861b4aeda8f9bb6c521e124360fd5821ef279fd9c7<br />

The request parameters to be signed, concatenated into a string is:<br />

zscm.local:10081:/ZendServer/Api/findTheFish:Zend_Http_Client/1.10<br />

: Sun, 11 Jul 2010 13:16:10 GMT<br />

From this value, an HMAC/SHA-256 signature will be calculated using the API<br />

key. For example using the hash_hmac() PHP function:<br />

785be59b7728b1bfd6495d610271c5d47ff0737775b09191daeb5a728c2d97c0<br />

The final request, including the added X-Zend-Signature header, is (lines are<br />

broken for readability):<br />

POST /ZendServer/Api/findTheFish HTTP/1.1<br />

Host: zscm.local:10081<br />

User-agent: Zend_Http_Client/1.10<br />

Accept: application/vnd.zend.serverapi+xml;version=1.0<br />

Date: Sun, 11 Jul 2010 13:16:10 GMT<br />

Content-type: application/x-www-form-urlencoded<br />

Content-length: 19<br />

X-Zend-Signature: angel.eyes;<br />

785be59b7728b1bfd6495d610271c5d47ff0737775b09191daeb5a728c2d97c0<br />

lookInCupboard=TRUE<br />

The server then proceeds to generate the same signature, based on the same data and same secret key.<br />

If the two signatures match, the request will be accepted.<br />

341

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!